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

learn more… | top users | synonyms

5
votes
2answers
57 views

Compose valid subtractions using all digits from a set

I have created a brainteaser, which I called the "impossible problem" (see this video I made). The aim is to create a valid 3-digit subtraction which uses every digit from 1 to 9 once. Here is an ...
2
votes
1answer
48 views

RPi script to periodically collect data from Arduino through serial port

I'm not used to Python. The script opens serial communications with an Arduino unit and send commands to and receives information from the Arduino. It is intended to run indefinitely until the system ...
1
vote
0answers
14 views

Connector for Odoo through xmlrpc (with testing code)

First time I write the tests before the actual code. All fit in the same module. ...
3
votes
1answer
26 views

Dynamic IP Notification Using Google App Engine

This script is very basic: it does one thing. Connect to it's root and it will log your IP if it has never seen it before. Connect to /logs, and it will show a list ...
3
votes
1answer
31 views

Learning nested for loops in Python with Pig Latin translator

I've been trying to learn Python for a bit now. I've taken a few courses, but I've found that I've been going about them wrong and had allowed them to "hold my hand" too much. I'm trying to build ...
1
vote
1answer
36 views

SoundCloud Top 50 Player

I wrote a Python 2.7 script, which plays tracks from the SoundCloud Top 50. ...
2
votes
1answer
26 views

Optimally allocating a resource with time-varying demand and cost

I'm working on the following DP which finds the optimal way to allocate a resource. At each time step I can either allocate (0.2 resources) at cost C or not in which case the storage is reduced by the ...
2
votes
1answer
51 views

Counting matches won by teams

This script counts how many matches were won by the team with a first half, second half, and full game time of possession differential advantage. The data is stored in a pandas data frame: ...
2
votes
2answers
72 views

Simple Rock-Paper-Scissors to get more comfortable with OOP

I'm trying to get a little more comfortable with using classes as they're meant to be used, instead of using them to decorate my code to make it look more legitimate. Can you see anything glaringly ...
1
vote
1answer
37 views

Find a specific file, or find all executable files within the system path

I wrote a function to find a specific file, or all the executable files with a given name and accessing flag, and I want to make ...
2
votes
2answers
29 views

Sending an SMS message using zenoss and python

I have just finished a simple python script which uses this module to call Zenoss API for getting live events. What the script does: connects to zenoss reads a file which has one phone number on ...
3
votes
0answers
30 views

REST API Calls to BIG-IP LTM to get the pool members and it's status

This code calls the iControl REST API provided by BIG-IP LTM. Trying to get the list of the pools, it's current status and the pool members associated with the pool. My code works like. First Call ...
6
votes
1answer
610 views

Breadth-first search on a tree in Python

The following code performs breadth first search on a mockup tree ...
1
vote
0answers
67 views

Submitting a JSON [on hold]

I have service to which I have to submit a JSON but I have to send the JSON multiple times and the code is slow. How can I improve the performance? ...
1
vote
0answers
16 views

Samba Access Wrapper V2

Follow up on this post. I created a Python module to access Samba shares some time ago, using Mike Teos' SMB module as some kind of a base to it. It is mostly a wrapper, but as I said, I wrote it ...
-1
votes
1answer
48 views

Computing logits for a vector and for all vectors in a set

I've had to write two different functions (shown below), but I want to combine the two functions into one. Is there a way to do this? softmax_a_set() takes a list ...
0
votes
2answers
58 views

Random Walk simulator seems slow, are there ways to optimize my code?

I'm trying to write a short random walk simulator in which an agent has a 50% chance on each "round" to either move toward x or back to its initial position. If the agent is already at its initial ...
4
votes
1answer
55 views

Calendar made with tkinter

I made a calendar that displays text documents according to month. Thankfully it works, although I could really use some help how to make it more better looking and efficient. I'm new to programming ...
6
votes
4answers
885 views

Python, JavaScript, PHP, HTML: Unbeatable Tic Tac Toe

At first, I created an unbeatable Tic-Tac-Toe in Python. However, I wanted a better interface, so I used a PHP backend that runs the script and a simple JavaScript that sends user commands to the ...
-4
votes
0answers
21 views

Very simple pong game in Pygame [closed]

How can I improve my code? I have been coding in python for a while and have just started pygame. I decide to make a pong/squash-esque thing. It took me about two hours. It is alright but it can ...
2
votes
1answer
12 views

Auto registering class registry

I built this auto registering registry to look into a package and import all modules and register any classes that are a subclass of a base class. I use it as a registry for a model's choices in ...
3
votes
1answer
53 views

Basic sorting in Python

Previously asked here. I would like to get my code for implementation of simple sorting algorithms in idiomatic python code reviewed. I am looking for feedback on python idioms used, better ways of ...
1
vote
1answer
73 views

Python implementation of Netcat, new design

I've made a simple netcat in Python and would appreciate any advice/opinions of how I've implemented it. test.py: ...
-4
votes
0answers
20 views

Maths Test Database Programme [closed]

I am writing a code for my coursework. It worked fine, however, instead of printing 10 questions, it would print 11 - so I changed the loop number from 10 to 9. It does ask 10 questions now, but no ...
2
votes
1answer
57 views

Find all distinct subsets that sum to a given number

The function wants to achieve to find all distinct subsets that sum up to an given number. ...
2
votes
1answer
66 views

Implementing basic sorting in Python

I would like to get my code for implementation of simple sorting algorithms in idiomatic python code reviewed. I am looking for feedback on python idioms used, better ways of doing the same thing. I ...
0
votes
2answers
34 views
1
vote
1answer
27 views

Quickly find percentile with high precision

I need to find the percentile where a list of values is higher than a threshold. I am doing this in the context of optimization, so it important that the answer is precise. I am also trying to ...
0
votes
1answer
39 views

Caesar Cipher Test

I've been studying computer science for around two school terms now. Currently, I'm making a Caesar Cipher program as a base for my examination, this is so that I can use the 15 hours to either add, ...
5
votes
1answer
117 views

Cyther: The Cross Platform Cython/Python Compiler

I am currently writing a Python library (soon to be published)that automatically compiles a Cython/Python file to pure -O3 C, without the user having to do anything ...
-1
votes
1answer
24 views
-3
votes
0answers
36 views

My python code is overly complicated. What's a better way of doing this? [closed]

ok so my code is basically a character sheet. I run the module and basically type whatever I want to see. Like this: ...
1
vote
2answers
43 views

GUI Caesar Cipher with model-view-controller

I created a Caesar Cipher Program in Tkinter, to help me learn the Model-View-Controller concepts and Tkinter in general. The code works, but it is a mess, and I want some help on cleaning it up, ...
3
votes
1answer
50 views

Python implementation of netcat

I'm trying to write a simple python script that acts like the nc program (netcat). I've got it working on OSX (the client that is) by testing against a netcat server, but I'm unsure about the way I've ...
4
votes
2answers
82 views

Simple text adventure game

I've decided to make a text adventure game but I feel that the code I have now is annoying, and as I get farther, it will make it hard to read. Is this a correct assumption? Please tell me what I'm ...
1
vote
0answers
21 views

Implementing Flask create_app function with SqlAlchemy

I have a simple Flask app that realises rest-api with SQLAlchemy. I have written this create_app function: views.py ...
5
votes
2answers
79 views

Python simple battleship game

I'm relatively new to Python, I decided to make a simple battleship game. Is there anything I should do to make it shorter, or in practice, "better"? ...
3
votes
1answer
68 views

Arithmetic quiz with class database and score analysis

I have done this quiz project and I have tried as hard as I could when I was writing to make it user friendly to read. Could you help me on improving and making it more user friendly please. ...
5
votes
2answers
78 views

Coloring a string in a terminal

I have this code which makes it easy to color a string in terminal but it is looking really repetitive. Is there a more idiomatic way of writing this? Also is there a functional way of doing this more ...
3
votes
0answers
13 views

Kivy language code of my Vehicle Details app

So I've written my first android app in kivy. This app takes a Vehicle License Number as input from the user and submits it to a sites and shows the results from the site. The complete Source Code ...
6
votes
1answer
34 views

Aligning out-of-sync subtitles

This is my 2nd program I wrote on my own, a pretty simple program consisting of two functions (those functions are not combined in any way yet though). The first function moves the display times of ...
13
votes
2answers
1k views

Python backend interview: task management system for workers

I've recently applied to a backend position and I was asked to complete a take-home interview question. I thought the question was rather simple and I completed in about an hour although I was told it ...
5
votes
1answer
146 views

Simple Hangman game in Python

I recently started learning Python, and made a simple text based Hangman game. I wanted to know if there could be anything done to make the code cleaner or more efficient. ...
3
votes
1answer
29 views

Putting a matrix from a text file into a list

I'm trying to read a text file with matrix and put it in a list, but I am using two loops here and I want my function to be faster. ...
1
vote
1answer
46 views

Charging battery animation over time

I have the following method that is working perfectly. Main problem I see is that I think it can be done just in one line, but I don't know how: ...
10
votes
4answers
123 views

n-queens puzzle in Python

I want to increase the efficiency and reduce the time complexity for the n-queen problem in n*n matrix chess. I am able to run only still (11*11) in normal time otherwise for the big number it is ...
4
votes
1answer
122 views

Finding the longest path, avoiding obstacles in a 2D plane

The Scenario You are given a matrix of size m x n (width x height) with m*n spots where there are a few obstacles. Spots with obstacles are marked as 1, and those without are marked as 0. You can ...
3
votes
2answers
152 views

“Guess my Number” game in Python (2.7.9)

First time posting to Code Review. Just looking to get some advice on how I can write better code. I found the following exercise for a "Guess my Number" game on DaniWeb, but the linked source code ...
2
votes
1answer
23 views

Redshift Load and Unload Wrapper class

We do constant traffic with our Redshift tables, and so I created a wrapper class that will allow for custom sql to be ran (or a default generic stmt), and can run a ...
-1
votes
0answers
46 views

Memory efficient alternative passing mostly static variables w/ 1 dynamic variable to an external function (COM) instead of a for loop in Python

Massive data problem, 7/8 variables are repeated 1000 times in a for loop, sending 8 input vectors * 50,000 values per loop for each function call. Only 1 input ...