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

learn more… | top users | synonyms

0
votes
0answers
37 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
12 views

Recursive function calling another function [on hold]

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? ...
3
votes
1answer
24 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
4answers
73 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 ...
4
votes
1answer
29 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
17 views

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

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 ...
4
votes
2answers
31 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
2answers
51 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
374 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
2answers
36 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
44 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
108 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
29 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
2answers
111 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
39 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
622 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
94 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
498 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. ...
4
votes
2answers
50 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
39 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
62 views

Simple 1-player Battleships game

This is my simple code for a Battleships game: ...
1
vote
0answers
33 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 ...
0
votes
0answers
20 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
257 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. ...
2
votes
1answer
27 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
24 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
25 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
41 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
38 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
21 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 ...
5
votes
1answer
61 views

.txt word-counter

I'm starting coding with Python (only able to use & create easy code!) and just created a word-counter. It reads a .txt file and enters the words in a dictionary with dict[word]="number of ...
2
votes
1answer
28 views

SQL GROUPING SETS in Python using Pandas

The code below is intended to provide SQL's GROUPING SETS functionality in Python with the aid of Pandas. Background on SQL GROUPING SETS There are at least two advantages to doing this in Python: ...
2
votes
1answer
57 views

2-opt algorithm for traveling salesman

I wrote a 2-opt algorithm to be used in a program and noticed (using profile) that the 2-opt is eating up a lot of time. I have tried a few things to make it run faster, but I am out of ideas. Any ...
3
votes
1answer
71 views

Look up parameters based on a numpy array of input values

Aim: Write a function that looks up empirical parameters A, B and C for a solar radiation ...
6
votes
5answers
200 views

First Hangman game

This is my first ever program created after reading a book on Python. Do you have any suggestions for me? Anything that are considered bad habits that I should correct for my new project? ...
11
votes
3answers
472 views

Predicting the next pseudorandom value

The archived material for the Stanford University course on cryptography at coursera.org includes a problem where you have to predict the next output of a weak PRG. It can be briefly restated as ...
4
votes
3answers
173 views

Sorting strings with certain restrictions

I want to sort a string which contains words and integers with the restriction that if the nth element in the list is an integer it must remain an integer and if it is a word, it must remain a word. ...
0
votes
3answers
57 views

Replace spaces in string

...
0
votes
2answers
52 views

Class CatalogWalker can walk thru a list of catalogs, calculate and report some statistics

Just for review and may be useful for somebody ...
0
votes
3answers
59 views

Permutation of phone numbers starting at button x, ending at button y, and z numbers long

I am trying find the total number of permutations possible with a given x, y, and z. x is the initial number, y is the final number, and z is the total number of buttons pressed. I am supposed to ...
4
votes
1answer
76 views

Speed up lights-out variant solver in pure Python

I'm doing some challenges to learn new and interesting concepts, this one is about a Lights out variant, instead of toggling only the adjacent tiles, it toggles the whole row and col. It must be ...
3
votes
2answers
97 views

Finding string roots

This is the following Python code that I have coded for an algorithmic problem online. For each line of input, the goal is to find the greatest number of repeating blocks into which the string can be ...
4
votes
1answer
41 views

Class representing both cartesian and spherical coordinates

I have had little experience with OO programming, being a typical engineer I tend to hack together functional code. However, I'm trying to change that and I see value in implementing OO when modelling ...
0
votes
1answer
34 views

Music note class - v2

Version 2 of Music note class in python ...
5
votes
3answers
276 views

Music note class

A class for notes calculation. ...