Use this tag if you are specifically using Python 2.7. Such questions should be tagged with [python] as well.
2
votes
1answer
11 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.
...
3
votes
0answers
21 views
Python Socket Receiver
I put this together and am having some doubts to the number of connections I can make. I also doubt if I can brute force the server to serve up connections and then hang.
Please take a look and tell ...
3
votes
1answer
29 views
Optimisation of a views.py for survey application
I have developed a small survey application in Django 1.6.2 which requires that the participants fill out a number of questions over 27 pages using a ...
2
votes
2answers
23 views
Optimisation of a forms.py for a survey application
This is my forms.py for a small survey application I am developing. I previously posted some of my models.py.
I am completely self-taught and am just looking for advice on how to improve. Any advice, ...
2
votes
2answers
36 views
Django Person Model created from forms.ModelForm
This is the current iteration of my first model of a Person. The model is populated by a survey application using forms.ModelForm and a ...
2
votes
0answers
30 views
Python deploy function using Fabric
Simple task - deploy war-file from TeamCity agent to remote web-server.
I realized it with Fabric, because of it make readable output, and give opportunity to ...
18
votes
3answers
2k views
“The python that ate a calculator”
In a YouTube video I watched, the speaker said it is important to know how to calculate between numbers of different bases; i.e. two, ten, and sixteen. I was then inspired to write a small C program ...
-1
votes
2answers
37 views
Varying the parent class dynamically in Python
I am trying to dynamically pick a parent class in Python 2.7:
...
2
votes
1answer
40 views
Argparse with subparsers
We have a main application made of a few separate parts - Unity and Clc.
I'm writing a new tool which will be used to manage them: deploy Unity, or run some checks and a lot of other stuff. As there ...
1
vote
2answers
48 views
Simple recursive function to find missing number in a permutation
This is a short and simple Python written to help me sharpen my dulling recursion skills. It expects a sorted permutation of integers n1..n2 in list format, with a single step missing (e.g., ...
0
votes
1answer
26 views
Canvas in Tkinter app for Conway's Game of Life updates so slowly
This is Conway's Game of Life written in Python and using Tkinter for GUI.
Problems are:
The "Play" button works so slowly. I can see how the canvas is redrawing from top to bottom. But when I ...
2
votes
4answers
84 views
Find the minimum number of coins
I'm trying to learn dynamic programming and the most popular one is to find the minimum number of coins for the change. I come up with this but I just want to improve this code which I think it could ...
4
votes
1answer
54 views
Sorting a list of names by greatest lexicographical order
This is a puzzle I found online that I have been trying to optimize and make the best version. The instructions for the puzzle are given below followed by my solution to the puzzle. I've tested it and ...
2
votes
0answers
21 views
Simulate object.__getattribute__ in Python
I want a Python example that illustrates how object.__getattribute__ resolves instance attribute lookups.
I'm looking for feedback about the following code. Is it ...
3
votes
1answer
53 views
XML generator function
I'm preparing a new tool for our deployment system.
One part of it is to generate a set of XML-files for modules.
The tool is really big, so I'll post only one function here for your consideration.
...
2
votes
2answers
29 views
Email log parser
This code parses mail server log files and outputs statistics into an external file. Is there a way to make it more pythonic? Is it a good idea to use regex anywhere? Which libraries can reduce the ...
6
votes
1answer
43 views
Nand2Tetris Code Module
I'm working through the Assembler assignment in the Nand2Tetris course (chapter 6). The suggested implementation contains 4 modules: Main, Parser, Code, SyntaxTree. Today I wanted to get some feedback ...
4
votes
2answers
76 views
CSV import-export in Python
I have finished a really short and small import / export script using Python 2.7, and now I would like to structure it using classes and methods where possible.
Could anybody give me some advice on ...
2
votes
2answers
98 views
Project Euler problem 23 - non-abundant sums
I present my solution for Project Euler problem 23 written in Python (2.7).
The problem statement is:
A perfect number is a number for which the sum of its proper divisors
is exactly equal to ...
1
vote
2answers
43 views
Avoiding regexps abuse in generation of statements to be executed
I made a GPL project to read Shogi Western Notations that I made public in GitHub. The project works perfectly on Ubuntu. Please check README.md to check requirements.
All this code works quite well. ...
4
votes
1answer
49 views
Tabulating a report
I have a method for generating a report in Python. I want to organize the section about the date into a separate method so I can repeat the report for different dates.
What's the best way to ...
4
votes
3answers
108 views
Build a dictionary based on split string
I've written a simple script that takes a string filled with brackets and strings and builds them to a dictionary.
Example Input:
...
3
votes
3answers
49 views
Diceware Passphrase Generator
I've written a simple Diceware passphrase generator based on this Stack Overflow question and the top answer.
Briefly, in the Diceware method, a die is rolled 5 times for each word in the passphrase ...
2
votes
1answer
44 views
Parse a string as a list of words and parse characters
I'm trying to create a list from a string with items alternating between words and parse characters like ['Hello', ' ', 'World']
Is there a built in function, ...
1
vote
1answer
88 views
Parsing video files from a given directory
I have written a little class that is basicly looking for video files in given directory and then parsing some info about those files. Finally it saves everything in a list.
To properly run this you ...
2
votes
1answer
59 views
Parsing oscilloscope data, follow up
Follow-up up on Parsing oscilloscope binary data.
I wrote a simple parser for Tektronix's internal file format .isf.
I revised my code to the following:
...
2
votes
1answer
40 views
SPOJ “SBANK - Sorting Bank Accounts” TLE
I am new tro programming and have chosen python 2.7 to begin with. But, I often have to deal with a TLE while competitive coding like in the problem below, where my code runs fine on all test cases ...
6
votes
3answers
79 views
Parsing oscilloscope binary data
I wrote a simply parser for Tektronix's internal binary file format .isf. The code is supposed to read in the file and return the header data as well as the actual ...
2
votes
3answers
68 views
SPOJ “To and Fro”
This is the To and Fro problem at SPOJ:
Mo and Larry have devised a way of encrypting messages. They first decide secretly on the number of columns and write the message (letters only) down the ...
2
votes
1answer
92 views
Web-scraping Reddit Bot
I have been working on a web-scraping Reddit bot in Python 2.7 with the premise of going to /r/eve (a game sub-reddit) finding posts that contain a link to a website hosting killmail information ...
1
vote
2answers
77 views
Making datastore inserts with Google App Engine and WTForms
I have a class for making datastore inserts with Google App Engine and WTForms. Now I want to refactor it into smaller units but I'm not sure how to do it. Can you help me find what needs to be done? ...
2
votes
1answer
30 views
Eliminating files that are completely contained within other files
I have a block of code that is really bugging me but I can't figure out how to clean it up. I have a list of objects which are all related. In fact some of them are complete supersets of one or more ...
5
votes
1answer
124 views
Sudoku Puzzle Generator
I've written a Sudoku puzzle generator. It currently runs through each line of the 9x9 grid and places numbers randomly if they're valid. It loops over all the numbers from 1-9 and then if it finds ...
4
votes
0answers
60 views
Artificial Neural Network implementaion
I'm looking for some general tips on code practices, doing things properly in idiomatic pythonic way. But mostly I want to know if this was build correctly. I tried making neural nets in the past, but ...
2
votes
1answer
38 views
Acquiring movie info
This code gives me info of a movie and the movies directed/acted by corresponding director and actors. It is working as the way I expected but I included lots of ...
2
votes
1answer
75 views
Populate a .txt document with a CSV spreadsheet using multiple templates, outputting documents for each data row
I'm looking for feedback on functionality, PEP8, advice, etc as a learning tool. I'm not sure how to tell if this program should be broken into separate functions or combined as one.
While hand ...
3
votes
3answers
72 views
Merging three CSV files with a primary key
This is my first time coding in my life. I don't really know much about coding. I googled whatever I need and combined them all together. It works great, but want to know if there is any improvement ...
2
votes
1answer
63 views
Drawing a cloud of points
I decided that it would be nice to write some code to draw a cloud of points.
Of course my first thought was to draw some random points but the result is not cloud-ish, it is well... random.
In the ...
2
votes
1answer
36 views
Return JSON data based on GeoDjango Queryset
My code below returns a JSON data based on user's input or query in my HTML page or template. However, I need to modify or do some tweaking with my JSON data in order for me to use it in my datatables ...
3
votes
1answer
84 views
Python mnemonic <==> hex conversion (Bitcoin BIP39)
Following up from the fantastic feedback re pbkdf2 code...
I'm looking for commentary on the following code, which converts from a hex seed to mnemonic (12 word phrase), and vice versa. It's for ...
4
votes
1answer
94 views
Python PBKDF2 using core modules
I'm trying to implement pbkdf2 in Python 2.7/3.4 without needing the pbkdf2 module. (I'm also trying to avoid using classes.)
Any insight would be appreciated:
...
3
votes
1answer
63 views
Testing Fibonacci conjecture
The sequence of Fibonacci numbers is defined as F1 = 1, Fn = Fn−2 +
Fn−1. It has been conjectured that for any Fibonacci number F, F2 + 41
is composite.
... [T]ask is to either prove the ...
2
votes
0answers
27 views
Identifying Polylines and operating on field values
I'm using Python 2.7.5 in a GIS environment (namely: QGIS 2.8.1, or PyQGIS).
sys.version_info(major=2, minor=7, micro=5, releaselevel='final', serial=0)
The aim is to identify spatially ...
4
votes
1answer
83 views
Reading in a series of Excel files
I needed to create a program which reads in a series of Excel files in folders typically structured something like this.
...
1
vote
0answers
60 views
File transfer using yandex.ru cloud storage
I've made a "envtransfer" application transfer environment between computers using Yandex disk application. I would like to hear the opinion of the code. Big thanks.
User authorize, get token, export ...
2
votes
0answers
156 views
A dictionary that allows multiple keys for one value
I'm trying to learn to program on my own with the help of books and the Internet and thought I'd start a project (a sub-project for a project).
I want to build a dictionary that allows multiple keys ...
3
votes
1answer
108 views
Instantiating a kind of NumPy array
I am creating a class object which must inherit from numpy ndarrays. I perform an isinstance check and an ...
8
votes
1answer
65 views
Ring datatype in Python
I wanted to write something that would be useful for the indices of a grid where if one walked off the edge of the grid they would re enter on the opposite side. This could in theory help with ...
6
votes
2answers
311 views
Project Euler Problem 12 in Python
I'm trying to do Project Euler Problem 12, which reads as:
The sequence of triangle numbers is generated by adding the natural
numbers. So the 7th triangle number would be 1 + 2 + 3 + 4 + 5 + 6 ...
2
votes
2answers
67 views
Bubble sort a list of integers for a number of iterations
I wrote a program for this problem, but it stopped because it took too much time. Any tips?
The Problem:
Bubble sort is the simplest algorithm for elements sorting. At each iteration we sequentially ...