Python is an interpreted, general-purpose high-level programming language whose design philosophy emphasizes code readability.

learn more… | top users | synonyms

2
votes
1answer
12 views

Better way to create a string of random characters

I'm generating domains with random names but I'm pretty new to python. I used the map function because it packages the results into a list which I can then join() into a string but the way I used the ...
0
votes
0answers
16 views

getting rid of proper nouns in a nested list python [on hold]

I'm trying to right a program that takes in a nested list, and returns a new list that takes out proper nouns. Here is an example: ...
0
votes
0answers
18 views

Python lottery game [on hold]

This is one of my first projects done entirely on my own without any tutorial and I am sure it is a little sloppy. Right now, I cannot figure out why my payout is always output as the payout for a ...
3
votes
0answers
28 views

Increase performance of Boyer Moore

Here is my Boyer Moore code in Python: ...
5
votes
1answer
36 views

Determining the least-accurately known physical constants

So, I thought I'd do this using scipy.constants: ...
3
votes
1answer
39 views

Python code which gives actual username from gmail id

If you have gmail id, then you can also receive emails on the same account even if you add extra dots in the username or add '+' and some characters. Say your gmail id is montypython@gmail.com, then ...
5
votes
2answers
60 views

Searching for files in a specified directory

I am currently writing a program that allows me to search for files in a user-specified directory. My current code is as follows: ...
5
votes
2answers
45 views

Python Email Program

I've written this email program in Python, and I would like to get some feedback on it. (i.e. closing the server twice after the raw input, etc.) ...
2
votes
0answers
27 views

Building a dict/list of lists?

I have code which is matching features within regions. The first thing it does it matches features from one region to an entire database of region features. So I have a mapping from query feature ...
7
votes
1answer
45 views

Making line by line replacements using values from multiple arrays

I currently have a Python script that parses a file (in this case an XML file) and makes line by line replacements as necessary, depending on the values of multiple arrays. As it stands now the script ...
0
votes
0answers
31 views

Captcha Maker program in python [on hold]

I have written a program to create an image consisting of randomly generated numbers using PIL. I have stored the numbers generated and compared it with user's input. ...
1
vote
1answer
49 views

Simple SAT Solver In Python

I am interested in improving my coding standards in Python so I decided to post one my more recent and smaller "for fun" projects here for review. The code below implements a rather simple ...
1
vote
1answer
33 views

A source Code Counter

This is from my project codecount I use personally that is very similar to cloc.exe or SLOCCount. The part that I am questioning is where I am calculating when I am in a comment block and have deep ...
0
votes
0answers
19 views

Python for loop [on hold]

I have a basic for loop in python that I'm wanting to run whereby I call a function and pass in a parameter that is varying from 480 to 6000 in increments of one...thus... ...
9
votes
4answers
312 views

Simplifying many-indents-code

I have the following code, written in Python: ...
7
votes
3answers
223 views

2-player in a Python hangman game

This is a follow-up: Python Hangman Program I'm working on adding a few features to my hangman game, and I just implemented two-player gameplay, in the form of one player chooses the word to be ...
2
votes
4answers
42 views

Comparing phone numbers across CSVs Python

(continuation from Speeding up and fixing phone numbers from CSVs with Regex) I'm pulling all of the phone numbers from all CSVs in two different directories, outputting them in a single simple ...
2
votes
2answers
91 views

Speeding up and fixing phone numbers from CSVs with Regex

I've hodgepodged together an attempt to extract all phone numbers from all CSVs in a directory, regardless of where they are and what format they're in. I want all phone numbers to be printed to a ...
9
votes
1answer
93 views

Automatically run doctest every time program is run

I would like this to happen every time I run a program from the command line. Is my approach Pythonic? I'm interested to know whether there is any problem with readability or correctness. Any general ...
4
votes
1answer
83 views

Installing Mods With Python (v 2.0)

My original code is here. I made some changes to it based on your suggestions, but then I lost my flash drive and had to redo it. I have a suspicion that my second version was better than this one, so ...
3
votes
1answer
43 views

Is the way I used threading in Python correct?

I'm learning how to use Python with the Raspberry Pi. I successfully followed the tutorial for how to have a Python script run on the Pi to check for new email and turn on a LED if any new messages ...
2
votes
0answers
37 views

Forcing base class functions to be used from the base class [on hold]

The answer to this question is probably "W-what!? What the !@#$-- Stop!! That's a terrible idea!", but I would like to hear your thoughts... I have two classes and one inherits from the other. ...
3
votes
0answers
28 views

Ways of speeding up this python implementation of SAT (Separating axis theorem)

A project I was working on required the usage of the Separating Axis Theorem to detect collisions between two convex polygons in real time. So I implemented a basic class (...
12
votes
1answer
75 views

Temperature Interpolation

I want to interpolate temperature in correlation with height. I have temperature data from stations with coordinates and height in this format: ...
5
votes
4answers
123 views

Guessing Game in Python

Now that I've got this working, any improvements that I can make to better my code review would be helpful. ...
1
vote
0answers
21 views

Parse Bloomberg Excel/CSV with Pandas DataFrame

First, please pardon my ignorance. This is my very first Python program. I retrieved Bloomberg data using the Excel API. In the typical fashion, the first row contains tickers in every fourth ...
2
votes
3answers
53 views

Raising error if method not overridden by sub-class

Background I have a base (only 2 classes inherit from it, and only from it) abstract (meaning I don't want it to be used directly) class that implements some common functionality. Some of it depends ...
4
votes
1answer
45 views

State Design Pattern in Python

I'm trying to find the best - read: readable, maintainable, robust, threadsafe, usable - solution for a State Machine in python. For this I've been looking at the State Design Pattern. However I want ...
6
votes
3answers
321 views

Project Euler 28 - Number Spiral Diagonals

Project Euler problem 28 I realized that the spiral was essentially an arithmetic sequence, so I based my code off of that. ...
2
votes
1answer
23 views

Project Euler 27 - Quadratic Primes

Project Euler problem 27 I decided to try simple brute force, and it worked surprisingly quickly. How can this be optimized? ...
2
votes
1answer
37 views

Scraping thefreedictionary.com

Scrape results from thefreedictionary.com ...
6
votes
1answer
23 views

Calculating Euclidean norm for each vector in a sparse matrix

Below is a naive algorithm to find nearest neighbours for a point in some n-dimensional space. ...
1
vote
0answers
16 views

numpy array as quasi-hash table

Motivation: I have a large number of large read-only dicts with large string keys mapped to tuples of two floats. They are taking up a large amount of heap space. Proposed solution: a 3xn numpy ...
-2
votes
0answers
43 views

Does anyone know how to solve this problem? [closed]

I already solved this but my program is too slow, I would like to see someone else's code if possible. It can be any language, but C, Python and Pascal prefered.
2
votes
1answer
89 views

Why does this Python maze-solver NOT get stuck?

I wrote the following Python program, which reads text files as mazes and displays the solution with a trail of Xs. The files must have an S for the start and an E for the end, and the walls must be ...
4
votes
1answer
57 views

Optimize vector rotation

I have a trivial function that rotates 2d vectors, and a method in a class representing a polygon that rotates every point in the polygon around an origin. The code is fairly optimized as it is, but I ...
4
votes
1answer
78 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? ...
2
votes
2answers
53 views

Python and Exception Handling IOError [closed]

I'm trying to work with exception handling by displaying "No Such File" when the file doesn't exist. I need to use a try statement. ...
3
votes
2answers
95 views

Recursive uniform cost search that needs to be optimized

I have this uniform cost search that I created to solve Project Euler Questions 18 and 67. It takes the numbers in the txt file, places them into a two dimensional list, and then traverses them in a ...
7
votes
2answers
65 views

Python Port Scanner 2.1

I made lots of changes to the script presented in my previous question. I was tempted to edit that one with the new code, but it would invalidate @200_success's helpful answer. It was also ...
4
votes
3answers
336 views

Can this list comprehension be made more pythonic?

Quite a specific question can the below code be made more clearer / pythonic in any way. Essentially based on the condition of the string x((len(x) / 3) - 1), I ...
3
votes
1answer
41 views

Python Port Scanner 2.0

A few months ago I put up a port scanner for review. Now, I've updated it with some new Python knowledge and integraing the feedback I got. Some things I specifically think might be wrong with it or ...
5
votes
1answer
39 views

Strongly connected components algorithm

In my Python application, I am using Tarjan's algorithm to compute strongly connected components. Unfortunately, it shows up under profiling as one of the top functions in my application (at least ...
8
votes
2answers
72 views

Comparing Server Version Number History

I have this code that compares all version numbers of servers. (The version numbers are stored in an XML file) Before the code would compare the current version number with the previous. This caused ...
0
votes
0answers
33 views

Learning using Neural Network

This is my code for MLP backpropagation. ...
7
votes
3answers
127 views

Can this rendition of Project Euler 26 be better written in any way?

This is my solution for problem 26 from Project Euler : ...
7
votes
3answers
142 views

Small Python calculator

I created this small Python calculator after abstaining from writing code for a while now. I would love seasoned programmers input. ...
7
votes
2answers
73 views

Python script to test music sight reading

I decided to write a program to test music theory, and, while it would've been much easier for me to make it elegant and perfect in Java, I thought I'd take the opportunity to get more familiar with ...
4
votes
1answer
39 views

Python auth using requests

I am trying to implement a custom ApiClient in Python, using requests. The way it does authentication is by: login(username, password) -> get back a token if valid, http error code if not set the ...
4
votes
2answers
43 views

Packaging a single-file Python copy-tool

I'm currently working on a very simple one-file project: Lumix provides the possibility for the camera TZ41 (and others) to load GPS data and tourist information from a DVD to a SD-card so that you ...