Python 3 is the latest version of the Python programming language and was formally released on December 3rd, 2008.

learn more… | top users | synonyms

2
votes
1answer
22 views

Python script to find large folders

I wrote this script a few days ago to find all files which were taking up over a certain threshold of memory on the hard drive. A hard drive on one of my computers had just 6 GB left, so I needed to ...
3
votes
2answers
47 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 ...
3
votes
2answers
61 views

Python Barcode Generator v2

This is a complete rewrite of the code posted for review in this question. The question is identical. ...
2
votes
3answers
62 views

How can I optimize this hash string function?

I'm writing a function which gets two strings and a number k as an input, and outputs a string with length k which is present in ...
4
votes
2answers
65 views

Class Vector with Python 3

Here is a class vector in python 3, for n-dimmensional vectors. Please suggest ways to improve the code as well as fix bugs and errors. The only rule is not using: numpy, sympy, scipy and so on. Only ...
2
votes
3answers
105 views

Python Barcode Generator

I was asked to provide some example code for a job interview and didn't have anything to offer, so I wrote the following function. A barcode generator may seem a bit basic, but there's some logic ...
5
votes
1answer
110 views

Python Back-Up Script

I wrote this script to backup some important files. It backs up the files to a local folder as well as to an external hard drive. It creates a new subdirectory which has its name constructed with ...
3
votes
1answer
78 views

ISBN Number Check

I’ve recently coded a way of checking a 10-digit ISBN. I was wondering if the code works to check the numbers, and if there are any flaws in my code. ...
3
votes
2answers
84 views

Generating a random string of characters and symbols

After coding this, I was wondering if there are any ways in which I can improve upon it. It generates a random string of characters and symbols the same length as what is entered by the user. It uses ...
4
votes
2answers
75 views

Measuring Execution Times

I was wondering which time.time() of from datetime import timedelta was the quickest and best way to find how long a programme ...
5
votes
1answer
46 views

Does this code actually give a valid representation of how quick a system is?

So I wrote this code a while ago as a way of seeing how many times it could compute a simple sum in a second (one tick). I was wondering if this gives me valid results or is in fact giving me bogus ...
6
votes
4answers
659 views

Are there any bugs or ways to make my divisor code better?

After coding my divisor code which I did as a practice for my GCSE stuff which I have to take soon, I have decided to ask the community if there are any bugs or ways I can improve my code. ...
14
votes
2answers
143 views

We'll be counting stars

Lately, I've been, I've been losing sleep Dreaming about the things that we could be But baby, I've been, I've been praying hard, Said, no more counting dollars We'll be counting stars, yeah we'll be ...
3
votes
1answer
75 views
5
votes
2answers
86 views

Geometry table for use in regexes

I have been teaching myself Python 3. I watched a video on YouTube entitled "stop writing classes". The Gtable class doesn't even have an init function, so I can't help but wonder if I should have ...
3
votes
1answer
38 views

Write and control Perlin noise for 1D

I'm reading this tutorial and it's the first time I try something this new. Here is my attempt: ...
4
votes
1answer
61 views

ASN.1 BER Encoding and Decoding

I have a project (ldaplib) I am working on that needs to do ASN1-BER decoding and encoding. The function I have for the decoding portion is slightly more complex but neither are all that complicated. ...
5
votes
1answer
77 views

Segment tree in Python3

I've implemented a Segment Tree in Python3: ...
5
votes
1answer
47 views

Determining the least-accurately known physical constants

So, I thought I'd do this using scipy.constants: ...
6
votes
2answers
78 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: ...
4
votes
1answer
84 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 ...
7
votes
2answers
88 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 ...
3
votes
1answer
57 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 ...
7
votes
2answers
76 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 ...
1
vote
1answer
102 views

Bank ATM program in Python

For homework, I have to code a program in Python that effectively simulates a bank ATM. ...
3
votes
1answer
51 views

Should I put python3 argparse filetype objects in a contextlib stack?

I just read the Lib/argparse.py code (class FileType) on http://hg.python.org/cpython/file/default/Lib/argparse.py. File objects are opened without the with statement. For safe file opening/closing, ...
7
votes
2answers
246 views

Wrapping my head around generators

I am going on with refactoring my code base while migrating from Python 2 to Python 3. I am using generators to make reusable components this time as I am more comfortable with them this time then ...
5
votes
1answer
94 views

Increasing readability of maximum path sum algorithm

I had written a solution for Project Euler problem 18 in Python 3. It is good in its efficiency but the problem is the readability and I think reuse. The algorithm used is that at every iteration ...
1
vote
1answer
59 views

Calculator for Mass

I've been trying to create a calculator to find mass using any and all known equations, the program will also return the steps used to find mass so the user can 'check their work' on physics ...
6
votes
2answers
231 views

Pythonic way to dynamically generate Strings (or other variables)?

I've got a Python script which is meant to launch several other shell scripts with the appropriate setup and parameters. I construct the file paths from other variables so that it's easier to change ...
10
votes
4answers
510 views

Suggestions for a Dungeons and Dragons-like game

This game is similar to a Dungeons and Dragons game. How could I improve the efficiency of the program? For example, where can I add functions, records etc? This is for a school Controlled ...
0
votes
0answers
33 views

Simple OpenID server that always returns “allow”

I have an application that uses OpenID for authentication. To test that application I've come up with the following: ...
12
votes
2answers
182 views

Drink order program

I'm looking to improve my code to make it more efficient, such as shortening it but continuing to gain the same output, or to add some more complex functions into the code. ...
3
votes
1answer
50 views

Time optimization of counting shifts in insertion sort

Is there any way of counting how many shifts would it take to count shifts while doing insertion sort? This is a Hackerrank problem. Here's my solution, but it takes more than 16 seconds. ...
5
votes
2answers
428 views

Sherlock and The Beast

I have recently written the program for the Sherlock and The Beast' HackerRank challenge. That's working fine, but the problem is that it takes too much time if a big number is given as a input. I ...
5
votes
2answers
819 views
0
votes
1answer
30 views

Calculating Leibniz of Pi [closed]

I have this Python program for calculating Leibniz of 'pi'. I am not able to shorten it more. Can anyone here optimise/shorten it? ...
2
votes
1answer
59 views

Verlet integration movement - doubt for on_key_press() methods

Based on my understanding of Verlet integration I tryed to use it over my Euler method to move my character in a 2D space. I will put only the neccessery code, but if anything else is needed I will ...
4
votes
1answer
97 views

Modified BFS code optimizations

I need some help reviewing this code in terms of making as fast as possible. This is a modified version of BFS that does quite a bit of processing on the side. Use case: I have a large graph ...
9
votes
1answer
80 views

Produce bitcoin private key from 31 playing cards

I've written some Python code to generate a random hexadecimal string using 31 playing cards drawn without replacement (so no card appears more than once). This is sufficient to provide more than 160 ...
5
votes
4answers
640 views

Sieve of Eratosthenes - Python

So I've been doing a lot of Project Euler lately and just wanted to make sure my implementation was as good as it could be. Does anyone have any suggestions to speed this up? ...
13
votes
2answers
162 views

Condorcet voting method in OOP Python

I'm currently learning Python and having a great time so far (coming from PHP, I have a feeling of suddenly seeing the light). At the same time, I'm studying voting algorithms. So, for training ...
5
votes
3answers
191 views

Code optimization for SQLite result set parsing

I am retrieving information from an SQLite database that gives me back around 20 million rows that I need to process. This information is then transformed into a dict of lists which I need to use. I ...
10
votes
3answers
340 views

Installing “mods” with Python

A little disclaimer: you're going to have a field day with this. It's horrible. Looking at it makes me want to vomit, and don't ask me to explain it, because I've long forgotten what I was thinking ...
4
votes
1answer
66 views

Cutting strings into smaller ones based on specific criteria

So, I've got this largish (for me) script, and I want to see if anybody could tell me if there are any ways to improve it, both in terms of speed, amount of code and the quality of the code. I still ...
5
votes
1answer
87 views

Hooking with Python3 Decorators

I wrote this prototype after reading the Wikipedia article on hooking. I didn't bother to read any of the code examples listed there because, well, I just didn't. I don't have a good excuse. The ...
7
votes
1answer
84 views

More efficient way of removing line indices?

After profiling my current script I've found that nearly 100% of the run time (and I'm not surprised) comes from the following function: ...
7
votes
3answers
196 views

Simple MPG calculator in Python

I am a self taught coder taking a Programming Fundamentals class to work towards a degree. It's based on Python, which I'm not as familiar with as other languages. I added error handling like I would ...
5
votes
1answer
309 views

Optimizing my code for Project Euler Problem #23 (Non-abundant sums)

Project Euler Problem 23 asks: A perfect number is a number for which the sum of its proper divisors is exactly equal to the number. For example, the sum of the proper divisors of 28 would be ...
3
votes
0answers
187 views

XLSX writer implementation

We have multiple scripts which write into XLSX with the same format, into a different format or slide variation. I am trying to write an API which saves time for other programs, but I need input on ...