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

0
votes
0answers
5 views

Python GUI for US ARL Dshell - Basics

I'm working on a Python 2.7 GUI for this program The GUI code is as follows: ...
-1
votes
0answers
13 views

Reducing nesting and number of if/else's in Python flow control

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 ...
4
votes
1answer
39 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
25 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 ...
6
votes
2answers
44 views

Shell sort function

I wrote a Python sort function that uses shell sort: ...
5
votes
1answer
33 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
36 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: ...
4
votes
1answer
49 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
87 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 ...
1
vote
0answers
29 views
0
votes
4answers
104 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
242 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
83 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
260 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
25 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
147 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
24 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
71 views
1
vote
1answer
66 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
510 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
222 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
50 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
50 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
29 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
41 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
74 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
63 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
46 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
214 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
177 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
54 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
122 views

Reading, writing and filtering a CSV file

I have a CSV with 5+ million rows and I want to filter it: ...
4
votes
1answer
53 views

Gmail Data Analysis

I am using Imaplib to fetch data from Gmail and get the number of emails each day. I am going to login using Imaplib twice for fetching emails for the inbox well as for the outbox (sent mail). Is it ...
6
votes
1answer
62 views

Enumerating Chess Piece Moves

There was a question asked recently here that went through enumerating moves for a chess piece. I was going to write an answer for this question, but while I was bashing out some code to throw into an ...
14
votes
3answers
1k views

Very simple Python preprocesser that allows “until” and “unless” statements

I've implemented the beginnings of a Python preprocesser I plan to implement sometime in the future, and the below code is my simple prototype. At the moment, it only converts ...
5
votes
5answers
165 views

Enumeration of random trees

I'm interested in recursive generation of trees in Python. For my eventual application, it's important that the trees be represented as a list of nodes (rather than say a dictionary, or an edge list, ...
3
votes
1answer
82 views

Fast row-wise, parallel calculations on large, sparse matrix

I have a big (50k*150k) matrix with co-occurrences of nouns (rows) and adjectives (columns). As most nouns don't co-occurr with most adjectives, this matrix is very sparse, >99.9%, so I'm using the ...
3
votes
1answer
52 views

Batch Gradient Descent running too slowly

Following Data Science from Scratch by Joel Grus, I wrote a simple batch gradient descent solver in Python 2.7. I know this isn't the most efficient way to solve this problem, but this code should be ...
3
votes
1answer
46 views

Downloading 2 tables from db, does calculation and uploads resulting table

I have written this script that downloads two tables from the db, preforms an intersection on them and adds 2 new columns to the resulting table, and uploads the resulting table to the db. It's a bit ...
4
votes
1answer
23 views

Move selection based on input for X, Y, and Z axes

My first use of classes with Python. Very simple code which I feel may be further simplified. Please break my code or give me input on where it could have been better/efficient. ...