Python is an interpreted, general-purpose high-level programming language whose design philosophy emphasizes code readability.
3
votes
0answers
83 views
Genetic Algorithm in Python
I'm a new programmer, so any help is advised. Preferably to make it faster, avoid heavy memory usage and so on.
EDIT:
Updated the code, now including a functional test program.
Fixed the PEP-8 ...
0
votes
1answer
43 views
A small backup script in Python
I work on ubuntu machine and my backup requirements are straightforward. My only requirement is the usual copy paste, but only changed files (ie. the files whose modification-time OR size has changed) ...
2
votes
0answers
19 views
School applicant form
I have created, in Django 1.6, a site for a school, where an applicant can get registered. It's a form that requests some information from the registrant and creates a random code for each applicant. ...
2
votes
1answer
25 views
Using a decorator to apply an inherited method to all child objects of the inherited type
I wanted to share this and get some feedback. My goal was to be able to have an object with methods:
...
2
votes
0answers
9 views
Parsing time ranges with PyParsing
The following code is intended to parse a string of the following format and return whether the current time falls in that window:
...
2
votes
0answers
39 views
Typeahead Talent Buddy
Problem is Talent Buddy.
Your task is to
write a function that prints to the standard output (stdout) for each query the user name that matches the query
if there are multiple user names ...
4
votes
0answers
180 views
Multithreaded file downloader using threading and signals
This is my first attempt to write a multithreaded application that downloads files from internet. I am looking for improvement in code, logic and better strategy for implementation.
Please ignore the ...
6
votes
1answer
76 views
Russian doll envelops
Interview question from the interwebz
You have a set of envelopes of different widths and heights. One
envelope can fit into another if and only if both the width and height
of one envelope ...
2
votes
3answers
70 views
Apple picking game. More efficient method than using global variables
I have been working on a small game called apple picker, it's text-based, and relvolves around picking and selling apples. Unfortunately I've been using global variables for this whole thing and it's ...
4
votes
2answers
89 views
Typeahead autocomplete functionality challenge
I'm working on a Talent Buddy challenge . In this challenge you have to design the autocomplete functionality of Twitter. You are given a list of queries and possible usernames. You have to return the ...
2
votes
2answers
54 views
2
votes
0answers
19 views
Python softmatcher using difflib impracticably slow
I have a softmatch function (below) that takes a donor list and a new entry and looks to see if the given donor already exists. The data is not exact, so I have to use a softmatch to determine ...
3
votes
1answer
23 views
Script for saving top wallpapers from wallbase.cc into a directory
I am newish to Python and I am looking for some extra eyes on a script I wrote. I wrote this script to learn more about web-scraping and using requests and Beautiful Soup. I use it to connect to the ...
1
vote
2answers
749 views
Function to store data in MySQL dabase (using OurSQL) is crawling
I am parsing a huge XML file. It contains some million article entries like this one:
...
0
votes
0answers
3 views
Implementing locks to make Google Search API ACID (Transactional)
x-post from StackOverflow, but I realized this question might be a better fit for this community.
I'm working on an AppEngine project that requires flexible searches over a dynamic dataset, and ...
4
votes
2answers
704 views
Does this one-line text-based terrain generator go against standards?
This isn't really a project, just something I threw together in 5 minutes. I just want to know if it goes with the current standards and if it should be changed.
...
3
votes
0answers
39 views
Python Multiprocessing: Using mutable ctype arrays seems to work, yet I am not seeing significant speed-up. Why?
As a brief introduction, I am student working on a body of code which forms part of my Masters' research - this is my first question on SO. My background is in physics and mathematics, so I will ...
3
votes
1answer
28 views
Persistent key value store for Python using SQLite3
This is a module to implement a key value store in Python using SQLite3. Originally written to allow sharing of configuration among multiple threads that are already sharing a SQLite3 database, I have ...
4
votes
1answer
49 views
Permutations program in Python
This code asks for letters and a number of letters per word and generates all possible permutations. Then compares those permutations with an English dictionary and creates a list with all the words ...
3
votes
4answers
959 views
Monte Carlo coin flip simulation
I've been learning about Monte Carlo simulations on MIT's intro to programming class, and I'm trying to implement one that calculates the probability of flipping a coin heads side up 4 times in a row ...
5
votes
1answer
64 views
Subclassing Flask for Permissions with Google App Engine
I'm trying to set up a very lightweight permission system using Google App Engine and Flask.
The end result I am hoping for is that each individual view is its own permission, and in an admin panel ...
2
votes
1answer
33 views
More Pythonic version of finding substring with one glob-like expression
Giving the following example list the task is: find out whether the
second expression is in the first one. * shall be considered as a
wildcard for any ...
7
votes
3answers
201 views
Saving high scores in a pickle database
Seeking to improve upon my high score 'module' code. It saves users' high score in a pickle database and if needed prints out the current scores in the database.
...
1
vote
1answer
72 views
7
votes
1answer
80 views
Is this implementation of persistence OK?
I'm using this code in an app that has hundreds of daily users. The code works, and passes all of the test cases I have.
Occasionally some users report a problem that I don't get right to the bottom ...
4
votes
3answers
260 views
Understanding the differences: A direct comparison between Cython and C++ [on hold]
Introduction:
The following two code samples are a direct comparison of performance between Cython and C++. I pieced them together with the help of others-- I barely understand how they work. Their ...
2
votes
1answer
27 views
Python Vector implementation that acts as a class and also a collection of staticmethods
Recently I've been wondering about ways of implementing objects in code that can be represented by other primitives. An example of this is a Vector, which can be represented by a Vector\$N\$D where ...
7
votes
1answer
93 views
Improved minimal webcrawler - why is it so slow?
I recently made a webcrawler that I submitted here for a review:
Minimal webcrawler - bad structure and error handling?
With that help, I've made a much cleaner and better(?) webcrawler.
The only ...
10
votes
1answer
347 views
Minimal Python plugin mechanism
Is there a better way to have a minimal Python plugin mechanism than the following?
(This was inspired from this post.)
...
6
votes
1answer
59 views
Flatten double-linked list
Consider this interview question:
Given a Node with a reference to a child, its next, its previous, and a variable for its value (\$\frac{1}{2}\$ tree, \$\frac{1}{2}\$ doubly linked list ...
5
votes
1answer
26 views
Refactoring Tkinter GUI that reads from and updates csv files, and opens E-Run files
Background
My lab administers four computer programs in three separate appointments. At each appointment, the subject does the programs in a pseudo-randomized order. Also, three of the programs have ...
0
votes
2answers
147 views
1
vote
1answer
33 views
Search a file system for files that match a given pattern
My concerns with this code:
Is there a more efficient way to find files by pattern in Python?
Does os.walk() work in Windows?
Is this code pythonic?
Should ...
4
votes
2answers
122 views
Python implementation of the Ramer-Douglas-Peucker Algorithm
I recently implemented the RDP polygon approximation algorithm in Python and I'm skeptical of whether or not I implemented it correctly of with the greatest efficiency. The algorithm runs in around ...
4
votes
2answers
1k views
Finding the largest product of four consecutive numbers in a grid
Project Euler #11 asks to find the largest product of four numbers of a grid, where the four numbers occur consecutive to each other vertically, horizontally, or diagonally.
Here is my solution in ...
3
votes
1answer
216 views
Integration of data using Simpson's rule
I wrote a Python program that performs an integration of data using Simpson's rule. The program takes the areas to be integrated from a foo.ref file, with the following syntax:
...
2
votes
0answers
72 views
Prototype spider for indexing RSS feeds
This code is super slow. I'm looking for advice on how to improve its performance.
...
4
votes
1answer
286 views
A simple little Python web crawler
The crawler is in need of a mechanism that will dispatch threads based on network latency and system load. How does one keep track of network latency
in Python without using system tools like ping?
...
3
votes
0answers
19 views
Personal Project for managing Bookmarks - View Part
The code is the view part of my bookmarker - project for managing bookmarks by categories. It uses Python 3.4/Django 1.6. I have also included models.py for reference.
The code does the following
...
1
vote
1answer
30 views
How to name this function which chains a number of callables into single function?
How would you name this function (I gave in a name pipe in the example) which constructs combines a chain of functions with a single attribute into a single ...
5
votes
2answers
42 views
Finding the best matching block/patch in Python
I wish to locate the closest matching NxN block within a WxW window centred at location (x,y) of a larger 2D array. The code below works fine but is very slow for my needs as I need to run this ...
4
votes
3answers
133 views
Tweets per second
This challenge is from Talent Buddy:
Tweets per second
Japan Castle in the Sky airing broke a Twitter
record on August 3, 2013. At one point during the classic anime movie
showing, people ...
7
votes
3answers
142 views
Script for finding cheating students in a quiz
Below is a script to find cheating students in a quiz in a daily moodle activity log exported in .xls. It works fine and is written in a procedural way.
Essentially the script isolates the activity ...
3
votes
1answer
45 views
Base class for subclasses that can track their own instances
I'm new to Python, with some background in Java and C# from a while ago, and more recently in scripting worlds like Bash and AppleScript.
I wanted to be able to create classes that could
report ...
-5
votes
0answers
27 views
I need someone to go through my conky scripts and correct my mistakes [closed]
I modified some conky scripts that I downloaded online. I cant quite figure out how to make the rss feed run. I tried two methods to get the rss feed - the rss command in conky (used in dinamalar ...
3
votes
2answers
51 views
String representation of a polynomial
We all know that math notation is idiosyncratic. Canonical representation of math objects often have irregular grammar rules to improve readability. For example we write a polynomial \$3x^3 + x^2\$ ...
4
votes
0answers
83 views
Replacement for commit_on_success
I am porting an application from django 1.4.5 to django 1.6.1. I found that commit_on_success has been deprecated. Moreover I found specific incompatibilities when ...
4
votes
1answer
60 views
Flood fill algorithm
I am implementing a flood fill algorithm using Python and NumPy. I have written the following fill function which works fine:
...
1
vote
2answers
275 views
The efficiency of looping over nested dictionaries in Python
How to make the following code more efficient?
...
0
votes
0answers
22 views
what to do to avoid Memory Error [closed]
I am working with quite large files (pytables) and I am having problems with the Memory Error when I try to load the data for processing.
I would like some tips ...