Use this tag if you are specifically using Python 2.7. Such questions should be tagged with [python] as well.

learn more… | top users | synonyms

1
vote
2answers
138 views
3
votes
4answers
68 views

Efficiently concatenate substrings of long list of strings

I am having performance problems with the following python function: ...
12
votes
6answers
1k views

Project Euler #1: Multiples of 3 and 5

Challenge Description: If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23. Find the sum of all the multiples ...
-1
votes
0answers
23 views

Django application - code improvements and best practices [on hold]

I have just finished a Django application, and I would like to get from you some code reviews related to my code. Application flow: Basically, my application is accessing a specific URL (always the ...
3
votes
2answers
44 views

Analyze very large sets of engineering data from Excel files

I am an electrical power engineer with some programing skills. My boss asked me to make a program which could analyze very large data, make some calculations and give the result. The task lookes like ...
11
votes
1answer
70 views

Racetrack plotter

My Racetrack is just that. A Racetrack. You can't race it (yet) because I had trouble with collision detection, but I wanted to share it anyway. It creates a base polygon by using ...
6
votes
1answer
51 views

Hangman with ASCII

I have just made a game called Hangman. I have added some stuff which people don't normally use, like cheat-code/s, time.sleep(). How can I improve this, in both ...
2
votes
1answer
57 views

Bot that selects web reviews based on spreadsheet entries

In my program, I prompt the user to enter a range of cities (in a spreadsheet), and then a range of review scores, and then make some decisions based on what the user has entered. Since the handling ...
6
votes
1answer
70 views

Builder - A 2D Minecraft clone

I was poking around on my Raspberry Pi that I hadn't turned on or used in a while, and I stumbled upon this Python script that I wrote ~1.5 years ago, and I was intrigued. Essentially, it's a 2D ...
2
votes
1answer
29 views

CSV parsing program that creates distinct header rows with transaction rows underneath

My code reads in the data using DictReader, then creates a header row that contains my composite key (PEOPLE_ID, DON_DATE), and then adds various values that are ...
7
votes
2answers
46 views

Shell sort function

I wrote a Python sort function that uses shell sort: ...
5
votes
1answer
34 views

“Increment” a string of uppercase characters

Given a string of uppercase characters, return a string corresponding to the next item in the following series: ...
-2
votes
0answers
38 views

A short and a readable implementation of Caesar cipher [closed]

I have a few lines of code for making a rotated string for a Caesar cipher and just for fun I am trying to condense them into one. Obviously this is pointless since it is completely unreadable but I'm ...
0
votes
0answers
23 views

Writing a generic getattr() and populate method parameters based on attr name [migrated]

I am trying to create a generic Python class for a Pub/Sub type app, where the model definition specified three methods for each type of resource X that we have: ...
6
votes
1answer
59 views

The dwindling Fibonacci

I've recently taken a renewed interest in non-standard languages like Brainfuck and TIS-100. I'm currently writing a Fibonacci generator in Brainfuck which differs a bit in approach from the usual ...
5
votes
1answer
115 views

A custom Pandas dataframe to_string method

Oftentimes I find myself converting pandas.DataFrame objects to lists of formatted row strings, so I can print the rows into, e.g. a ...
0
votes
0answers
30 views
0
votes
4answers
106 views

Performing add/delete/count operations on a list

Problem Statement (HackerRank) You have a list of integers, initially the list is empty. You have to process Q operations of three kinds: add s: Add integer s to your list, note ...
0
votes
1answer
246 views

Print the lexicographically smallest permutation that satisfies the given formation

Problem Statement: A DOTA game has N heroes, each with a distinct rank from [1..N]. In DOTA every formation is characterized as a permutation [1...N] of ranks of players. A formation is ...
4
votes
2answers
87 views

Google's Python exercise about lists very different from the given solution

Disclaimer: Although I do believe that this is somewhat a code review, I'm not sure if this kind of question applies to the site; if not, please let me know and I'll delete it promptly. I found ...
1
vote
2answers
35 views

Overall utility tool for a project that will create account lists for pulls

I'm creating a meta-utility tool for a project that I'm on that has a lot of repetitive tasks that can eat up a lot of time. My goal with this tool is to eventually be able to automate, or at least ...
4
votes
2answers
178 views

Searching within multiple objects of the bucket

I have millions of files in the Google cloud storage's bucket. I want to search within files with a .index extension and retrieve the contents. This is currently what I am doing, but the time ...
1
vote
3answers
25 views

Adding some config to a juniper device

I wrote this script to add some config to a Juniper device. It works well but the whole user input validation section (yes or no section) seems a little messy. Is there a better way I could have ...
3
votes
2answers
267 views

Finding the kth to last element of a singly linked list

I'm not sure if this code is industry-standard or not. Please review it and let me know if any improvement is required. ...
2
votes
1answer
26 views

Linux/Windows Text Editor in Tkinter

Over the past couple of days I have been working on a super-basic text editor with Tkinter. It can: Open new files Open files (general) Save files Obviously you can edit any file you open or ...
6
votes
3answers
154 views

Manipulating a .csv file to look for two common values to create a key, then summing up values

My code reads a .csv file, looks for a couple values to create its key, and then wraps up the data based on a few business rules I have. I'm trying to learn "the right way", so I'd really appreciate ...
4
votes
1answer
26 views

Solving a variation of the “Partition Problem”

In my version of the Partition Problem, I have a set of weights that are all powers of three (1, 3, 9, 27 etc.). I only have one of each weight. There is some object (the weight of this object is ...
2
votes
1answer
75 views
1
vote
1answer
74 views

Converting an image from polar to cartesian coordinates

I have the following code which has too many loops inside it (almost 13 billion). This code is actually for image processing. I am first making a matrix of dimension 1024*360. This is the value of the ...
7
votes
4answers
515 views

Number guessing game for beginners

I am teaching a python class to some high school seniors. I was thinking of doing an "oracle" game where the computer would come up with a number, and the player would guess it. These are brand new ...
4
votes
1answer
61 views

Checking for legal sudoku boards

My problem statement is: Write a function to indicate if a given Sudoku board is legal. This function takes a Sudoku board (which you may assume is a N2xN2 2d list of integers, where N is an ...
6
votes
4answers
224 views

Checking a word grid

I wrote this program where you can input x amount of words that of length x that checks if the grid formed is the same words ...
6
votes
1answer
51 views

Game loop decorator for Pygame

I've built a simple decorator that wraps a function in a general Pygame game loop. It also allows for the programmer to set the tick rate. ...
7
votes
2answers
42 views

Data reduction program

This is my first program in Python and first time I'm writing in dynamically typed language. I have substituted real detectPeaks function with a simple placeholer. ...
0
votes
1answer
51 views

Encryption via multiplication of hex-converted, multiplied ASCII values

The idea behind the encryption is that it stores the key within the final encrypted password. When the user inputs a password for the first time, they also have to pick an element from a list of ...
0
votes
1answer
31 views

Converting from POS tagged word-tokens to POS tagged Phrases

I have sentences expressed as Parts of speech (POS) tagged words. I want to have all the short phrases in them to be joined up with underscores. I want them to have the Part of speech tag of the final ...
3
votes
1answer
40 views

Class modelling for a shogi notation reader

I have made GPL software in GitHub whose purpose is reading shogi notations (shogi is Japanese chess). I have been told that my software modelling is underdeveloped in this question and advised to ...
3
votes
1answer
42 views

Separate roles into modular parts that are interdependent

I have a IRC bot that I'm writing (code is here, bot24-irc.py is the main module). This bot needs to be able to perform many different, separate roles so that each can be reloaded and sandboxed (for ...
7
votes
1answer
48 views

Querying houses similar to a given house

I was given this task as an interview coding challenge and was wondering If the code is well structured and follows python guidelines. I chose to sort the houses based on a similarity metric and then ...
6
votes
1answer
75 views

Multiprocess Bogosort

I only program by hobby, and I'm trying to improve with Python, so along with practicing coding I decided to venture into multiprocessing. This is a command line and will sort a variable number of ...
4
votes
1answer
42 views

ConfigParser - class for configuration managment

I writing tool to manage our application. One part of it - is INI-file, which contains UUIDs for some application modules. It looks like: ...
7
votes
2answers
75 views

Parse and write data from/to a xml file

I recently started to learn Python for the purpose of making my life as a network engineer easier when performing repetitive tasks. The script below does parse a huge inventory.xml file I get from a ...
7
votes
1answer
50 views

Python XML parsing, extraction and renaming files

I've written some code to: Parse an XML file. Extract some strings. Make copies of the original XML whose names are suffixed with the extracted strings. Please review this. ...
4
votes
2answers
216 views

Project Euler Problem 5

I wrote up a small script to calculate the answer to Project Euler Problem 5: 2520 is the smallest number that can be divided by each of the numbers from 1 to 10 without any remainder. What ...
8
votes
2answers
180 views

Reusable, generic save method

I am developing a Python script that will process large amounts of data from an experiment. Files are read in, calculations are made, images are plotted and saved as .pngs, and calculated parameters ...
3
votes
2answers
57 views

Testing hard drive write/read performance

This is a simple example of script to run the CDM to test the performance consistency of the drive in Windows environment. Please let me know if you find any place can be better improved,(it may be a ...
2
votes
0answers
35 views

Passing around and using Python dicts [closed]

I have an Excel file - a profit spreadsheet - which has one tab per product range. The tabs are defined and named, but apart from that, the file contains no data (yet). I wish to use ...
3
votes
1answer
129 views

Reading, writing and filtering a CSV file

I have a CSV with 5+ million rows and I want to filter it: ...