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

learn more… | top users | synonyms

2
votes
1answer
39 views

Prime Number Sequence generator

I have just started using Python, and I am attempting to make a prime number sequence generator, where it will print the a specified amount prime numbers in terminal. I have other versions of this ...
-2
votes
1answer
27 views

Generating all permutations of a list [on hold]

I'm looking for feedback on the following functions to generate permutations of a list. I'm new to programming and did this as an exercise after taking an on line algorithms course. I think it is ...
3
votes
5answers
289 views

Hangman game in Python

While I'm not new to Python, this is my first 'bigger' Python program I created, also my first game in Python. ...
4
votes
3answers
194 views

Random walk in Python + turtle

I decided to implement a random walk. The rules The rules are easy, an object is moved in the direction dictated by random or pseudo-random numbers. If you want to read more about it, see the ...
3
votes
1answer
10 views

Copies inventory data from multiple excel worksheets to individual excel delivery notes

I am new to Python and am looking for any feedback/criticism on scripts I have written for work. This script works as I intended, creating multiple .xls files from a workbook with multiple ...
0
votes
2answers
31 views

Merge two dict in separate list by id

I have following data structure >>> a = [{'id': 1, 'name': 'a'}, {'id': 2, 'name': 'b'}] >>> b = [{'id': 1, 'age': 12}, {'id': 2, 'age': 21}] I ...
2
votes
1answer
35 views

Roughly removing 'duplicate' photos based on filename

I quickly wanted a script that'll go through a lot of photos in a folder and only keep one photo per minute (gotta love burst shots on iPhone). Fortunately, Dropbox names them with a timestamp upon ...
2
votes
2answers
40 views

Function caller (to multiple receivers) interface

This class is designed to call a similar function of multiple objects of multiple classes using a single interface (it is not for calling functions that return a value). A potential usage will be ...
2
votes
2answers
96 views

List comprehension: avoid duplicate function call

to_convert_files = [FileEnc(filename, getEncoding(filename)) for filename in filenames if getEncoding(filename) != None] The problem here is ...
1
vote
0answers
18 views

Python, testing user input speed with random phrase [on hold]

This is a plugin for a Jabber/XMPP bot which gives the user a random phrase, and starts a timer in milliseconds, when the user replies with same phrase, the bot replies with the timer. Now these the ...
5
votes
1answer
37 views

Custom Google App Engine Python user managment

I've written this script as a basic authentication system for use on Google App Engine. I would appreciate it if anyone would mind having a look and seeing if there are any obvious security ...
5
votes
2answers
21 views

Activity-based permission checking

I threw together this Python function to check if a User has a certain Permission. First of all, Permissions have this kind of format: ...
-4
votes
0answers
16 views

aggregation using Python 3 with Tkinter — not behaving as desired [on hold]

when I fill the entry 'enter new name, get IQ' with the name of the fighter and click button 'test it out!', i want it to access the IQ field from the BaseCitizen object [that was already aggregated ...
11
votes
3answers
114 views

Becoming the greatest tower builder

I am trying to learn how to write proper code in python, and stumbled upon the following problem. Bob is given a set of building blocks b, and a number ...
5
votes
1answer
51 views

Isprime Android app with kivy

I thought that developing an app in Python should be easier than learning Java. I finally got my isprime app to work but it looks ugly. When I write GUI code I always find myself typing in very long ...
1
vote
2answers
69 views

Class for multithreaded insert into database

Here I have class that supposed to take dictionaries of product objects and their articles (kind of unique identifier) from queue and insert or update them in database table. Received dictionary ...
-2
votes
0answers
17 views

Recursive function calling another function [closed]

I'm new to Python and I made this recursive function with a non-recursive function as one of its arguments. I was expecting it to print 4 times but never did. May I know what I'm missing? ...
4
votes
2answers
34 views

Mailinator automatic checker for new e-mails

I'm making a little script to run on the background and notify me when I received a new email in a mailinator inbox. I want to eventually daemonise it, but for now it just runs like a regular script. ...
3
votes
5answers
92 views

Finding the occurrences of all words in movie scripts

I was wondering if someone could tell me things I could improve in this code. This is one of my first Python projects. This program gets the script of a movie (in this case Interstellar) and then ...
6
votes
2answers
47 views

Modular arithmetic brute-force congruence finder

My full code is running too slow. I do profile.run to my project and found out this function consumes a lot of time. The main problem is just to return an array containing all \$x\$ satisfying both ...
0
votes
0answers
22 views

Conway's Game of Life, OO in Python [closed]

Below is the code I wrote for my OO-Conway's Game of Life. It appears to be consistently counting neighbours incorrectly and I cannot seem to find the source of the error! Any assistance in finding ...
5
votes
3answers
48 views

Extract room sizes & room types from an estate description with regex

I'm trying to extract room types and sizes from a descriptive text utilizing the following scripts as an exercise. Any tips on being more pythonic would be amazing! The script is based off the help I ...
4
votes
4answers
71 views

Calculate all cyclic subgroups of a group under multiplication of modulo n (group theory)

The task was to calculate all cyclic subgroups of a group \$ \textbf{Z} / n \textbf{Z} \$ under multiplication of modulo \$ \text{n} \$ and returning them as a list of lists. The first level has all ...
10
votes
2answers
383 views

Project Euler #22 - Names Scores

I programmed Problem #22 from Project Euler in Python. It works but I want to know if it really is pythonic enough. Using names.txt (right click and 'Save Link/Target As...'), a 46K text file ...
7
votes
3answers
50 views

Checking for intersection points

The aim of the program is to find those points which comes under the intersection of at least 2 circles.(space is a 1000x1000 matrix) ...
10
votes
1answer
47 views

Class used for stochastic epidemic simulations

I've developed a class used for some epidemic simulations I'm doing. Individuals are 'S' (susceptible), 'I' (infected), or 'R' (recovered). These are standard abbreviations in the research ...
6
votes
3answers
115 views

Simple addition, multiplication, divison, and subtraction program

I made a post a couple of days ago asking if anyone noticed bad habits or thought of any suggestions: (First Hangman game) I've made 2 math programs just to make sure I got it all down pat. The first ...
3
votes
0answers
38 views

Scraping efficiently with mechanize and bs4

I have written some code that scrapes data on asteroids, but the problem is that is super slow! I understand that it has a lot to scrape, but as of now it has been running for 5 days and is bot even a ...
5
votes
2answers
44 views

Stochastic simulation event timing

So I'm learning bits and pieces of python. Here's some code that just doesn't seem pythonic, and I'd like to improve it. I'm doing stochastic simulations with a Gillespie style approach, but if that ...
5
votes
3answers
129 views

Julia RPN calculator algorithm ported from Python version

I've just finished the Reverse Polish Notation task in Julia from rosettacode.com by porting the existing Python code. There are only a few lines I don't get how to port: ...
2
votes
1answer
40 views

Process zip files

I have zip bundle, for example, abcd.zip, contains more zips like 1.zip, 2.zip etc. Inside of each child zip there is a .jpg file like 1.jpg, 2.jpg etc. There are so many other files but I need only ...
13
votes
2answers
631 views

FizzBuzz example in Python for game manual

I'm developing an implementation of the FizzBuzz game as part of an edutainment game for a retro video game platform. In its manual, I want to mention the history of writing a bot for the FizzBuzz ...
-3
votes
1answer
96 views

Returning player that belongs in two organization lists

I'm using a list comprehension to find an object that matches in two lists and return the object for its property. I know the object ALWAYS exists in both lists and no other item in the lists are ...
10
votes
3answers
499 views

Counting Vowels

I'm learning to program and I've chosen Python as my first language. I've written a function to count vowels in a string and print the number of occurrences of each of them. Please review my code and ...
4
votes
1answer
38 views

Returning items that meet a minimum value

I'm trying to find an alternative way to write this code such as using different ways to achieve checking if it's a subset and insertion. ...
5
votes
2answers
52 views

Creating a table using given items

This simply creates a table using the items passed in. I would like to make this function shorter and/or more efficient. What I have seems pretty redundant. ...
3
votes
1answer
43 views

How can I ensure some structure for classes for a plug-in system written in Python?

I have written a toolkit (hwrt) which has a plugin system. One type of plugin is a feature (see this) for many of them. There are some restrictions of feature ...
5
votes
1answer
65 views

Simple 1-player Battleships game

This is my simple code for a Battleships game: ...
1
vote
0answers
34 views

How common is the use of closure in Lisp?

I'm writing a little tool for mangling MP3 collections and, as a challenge, I decided to write in in Hy, a dialect of Python that uses Lisp syntax. Like every good developer, I wrote out my list of ...
1
vote
1answer
31 views

A translator class in Python v2

Version 2 of A translator class in Python Changes: Style compliant to PEP8 Both orig_str and filename allowed to be any ...
11
votes
2answers
267 views

Python review_generator

Given a Python file containing a Python script written with bad style, this script will output a review adressing its problems. ...
3
votes
1answer
30 views

A translator class in Python

This class can be used to access the Google Translate web interface and get translation result for large text (split up into sentences). The Signal class is copied ...
2
votes
1answer
25 views

Write to a new, modified Excel file from an original one

I noticed that I've a HUGE bottleneck in this following function of mine. I can't see how to make it faster. These are the profiling test results(keep in mind that I'm using a PyQt GUI so times can ...
3
votes
2answers
27 views

Generating playing cards

This code has several functions and procedures for the program to generate cards like '5 of diamond'. I would like to shorten the code. ...
2
votes
0answers
45 views

Confidence score calculation

I was looking for a way to calculate a score 'x' for each pair of elements in two separate arrays. The goal of the code is to return an output array containing the score for each entry in the input ...
3
votes
2answers
40 views
3
votes
2answers
45 views

Distribution problem optimization

The situation is this: I have a bunch of servers which are synced so that they all have the same data. Unfortunately, a disaster happened and the servers are all out of sync. My task is to re-sync all ...
2
votes
1answer
23 views

Keeping track of calculation dependencies

Suppose I have a set of calculations: x = x() y = y(x()) z = z(y(), x()) I would like to create a Python class to implement these calculations, being mindful of ...
1
vote
0answers
26 views

A scalable function for get boundary vertices in a graph

Given a community division I need a list of vertices that have edges in more than one community, i.e., boundary vertices. I've tried this: ...
4
votes
2answers
45 views

Team git commit cleaner

I cleaned a big repository for my team with this Python code. My goal was for every developer in my team to check if some bad email are in the commit, and replace the information by the good one. I ...