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

learn more… | top users | synonyms

3
votes
2answers
27 views

Factorisation code running slow

I'm still in the process of learning Python and am doing some of the Project Euler problems. I have made a factorisation algorithm that works; however, it runs really slowly, and I'm not too ...
3
votes
2answers
53 views

Summation and product functions using functional paradigm

Below is the problem: Show that both summation and product are instances of a more general function, called accumulate, with the following signature: ...
0
votes
0answers
23 views

CAPTCHA reader and maker

I've made some CAPTCHA reader and maker in Python using Tkinter. Do you know if it's possible to keep image and output files in "memory" not writing them on disc? Because right now everything is ...
5
votes
4answers
606 views

Simple Rock, Paper, Scissors in Python

I have looked at many different approaches to this game online, but as someone who isn't very experienced with Python, I may not be aware of what others are doing right. Here is my code: ...
-4
votes
0answers
39 views

Pokemon type game in python 3 [on hold]

Im trying to make a simple pokemon style game in python 3. I sucsessfully made the game with 3 moves that the player could use: punch kick or heal. I then wanted to expand the game and add other ...
2
votes
1answer
31 views

Project Euler #10 in Cython

I'm trying to teach myself some Cython. To do so, I use Project Euler #10: The sum of the primes below 10 is 2 + 3 + 5 + 7 = 17. 2 Find the sum of all the primes below two million. My Cython ...
3
votes
1answer
90 views

Counting Lines and Sum of Lines

I have a small function that when passed a str that names a file that contains a program; it returns a 2-tuple with the number of the non-empty lines in that program, and the sum of the lengths of all ...
3
votes
2answers
85 views

Recursive functions for sorting

I made a few recursive functions for learning purposes which do a variety of tasks. Here is my current and functioning code: ...
4
votes
2answers
114 views
+50

Functions with mutable and non-mutable named tuples

I am making some functions within a function for learning which when passed information about a named tuple: it returns a reference to a class object from which we can construct instances of the ...
5
votes
1answer
58 views

Flooring cost calculator

I've made a small program that calculates the cost of flooring for a given area based on the price per sqft and total sqft. I have only been programming for a few days now so I am sure that there are ...
0
votes
2answers
69 views

Two permutation iterators for classes in Python with and without a generator

I am just testing out a couple of small classes for learning purposes. Here is my current working code: ...
3
votes
3answers
70 views

Functions taking iterables: peaks, compress, and skipper

I am just testing out a few small functions for learning purposes: ...
4
votes
4answers
133 views

Hailstone Sequences in Python

For the problem given: Douglas Hofstadter’s Pulitzer-prize-winning book, Gödel, Escher, Bach, poses the following mathematical puzzle. Pick a positive integer \$n\$ as the start. If \$n\$ ...
10
votes
2answers
128 views

Gimme some random passwords

pwgen is a nice password generator utility. When you run it, it fills the terminal with a bunch of random passwords, giving you many options to choose from and ...
3
votes
1answer
32 views

Disjoint-set data structure in Python 3

Inspired by this question, I decided to implement a Disjoint-set data structure in Python 3. I mainly followed this description for understanding the algorithm (but did not do the optimizations for ...
2
votes
1answer
65 views

Little command line video grabber

I made a little Python3 script to grab video clips from a website for viewing off-line later and would like your critique, advice, tips & tricks and/or learning resources to create better code. ...
1
vote
1answer
27 views

Expiring in-memory cache module

I needed a simple expiring in-memory cache module for a project I'm working on and I've come up with the following. My requirements for the cache module are: Be able to expire objects after certain ...
3
votes
1answer
56 views

Solution for puzzle 3d x 1d = 2d x 2d in Python

I wanted to resolve the puzzle from this link using Python 3. It works and gives me the correct value but I would like to know if it is possible to resolve this problem with a few lines or how I can ...
2
votes
2answers
88 views

Bag data structure (a set that can store multiple copies of items)

I am trying to make my class a bit cleaner, especially some of its methods like Count, __add__, ...
15
votes
1answer
183 views

Modeling a Mage character from nWoD, using Django

Goal Design a representation of a mage character from the World of Darkness RPG, as well their associated spells. Here is a visual representation of the schema. You can see it more closely ...
2
votes
1answer
31 views

Python object modelling with ABCs

I'm modelling the core entities in a callcenter-related system that deals with Operators and groups ("pools") of them. While I've written some Python before, this is my first time building a larger ...
1
vote
1answer
40 views

Python decorator for optional arguments decorator

I want my Python decorators to have optional arguments and not be called when not necessary. The accepted answer in here doesn't accept named arguments, and I don't want to add boilerplate code ...
3
votes
2answers
29 views

Create SQLite backups

I have this script for creating SQLite backups, and I was wondering whether you'd have any suggestions on how to improve this. I was thinking that maybe it should create the backup ...
5
votes
2answers
215 views

Interleaving values from several iterables

I am new to Python and am trying to see if there is a cleaner way to write my code. The following code take iterables as parameter it produces the first value from the first parameter, then the first ...
2
votes
1answer
31 views

All-in-one number base converter

I coded this program as a challenge for /r/dailyprogrammer. Basically this program can convert any number from any base to another base including negative bases as long as the input is coherent. Did I ...
5
votes
1answer
65 views

Simple encryption based on MD5

I made a Python 3(.4.2) program that only adds classes and is meant to be imported. It allows the creation of files that store usernames and hashed passwords. It uses salting as well. It also can ...
3
votes
2answers
351 views

Project Euler #14 solution takes quite a long time

Can anybody give me suggestions for making it faster? (Project Euler #14) ...
3
votes
2answers
47 views

Python path-breaking script for use in R

R does not support line continuation as Python, and it's disturbing to have long file paths like /media/user/data/something-not-very-important-but-super-long/some-curious-secret-file.pdf and ...
2
votes
1answer
42 views

Books Algorithm Dealing with Square Digit Sums

A little context: Book has 411 Pages Read a random number of pages on the first day which is unknown Number of pages to read next day is the square of the sum of the digits of the page ...
4
votes
1answer
129 views

Python prettyXML and prettyHTML functions

After much searching around the web, I couldn't find a single module which did a decent prettyXML or prettyHTML. Because: ...
4
votes
1answer
81 views

Finding the minimum number of required deletions to have a non-repeating string

I wrote code for the following problem: Given a string, print out the number of deletions required so that the adjacent alphabets are distinct. Please suggest different methods by which I can ...
1
vote
2answers
72 views

Book pages algorithm dealing with digit sum and squares [closed]

I would like some help condensing this code to make it more efficient. Could someone also help me output the number of pages she reads instead of the page number she is on... ...
4
votes
2answers
53 views

Faster way to perform function calculation in Python?

I'm interested in whether there is a way to further improve a "fast" version of a function used in a homework assignment I received recently (I've already submitted the completed work). ...
8
votes
1answer
151 views

Python-based Git pre-commit hook to manage multiple users/Git identities

A couple of months ago I posted a bash script to manage multiple Git identities as a solution on Stack Overflow but soon found the hook isn't flexible enough. Thus I decided to rewrite the hook in ...
0
votes
0answers
43 views

Simple k-means implemention using Python3 and Pandas

Is there anything I can improve? The distance function is Pearson correlation. ...
5
votes
3answers
396 views

Truth Table Calculator

In of my software engineering classes, I had to write a truth table calculator in the language of my choice. This is what I came up with, and I would like to know what I should do better next time: ...
1
vote
0answers
39 views

PyQt5 GUI Application

I'd just like this PyQt5 code reviewed. I'm relatively new to classes and GUI programming, and wanted to make sure I wasn't doing anything too bad. If absolutely necessary, I can give you the other ...
3
votes
2answers
126 views

Validate Move Pattern Chess

A while ago, I was working on a chess project with a couple other people. In the end, I wrote all but a couple of the lines of code, including these: ...
3
votes
3answers
67 views

CR2 raw image file parser in Python 3

I haven't used Python in a number of years, but recently started working on a project called Photoshell which is written in Python 3. As I attempted to learn the "Pythonic way", I wrote a parser for ...
5
votes
1answer
132 views

Object-oriented Conway's Game of Life

I have Conway's Game of Life working now and was hoping for direction on: Unclear code - where would comments make it clearer? Poor design choices - I already know of one in the ...
2
votes
1answer
56 views

Autoclicker Tkinter Program

I made my first program that I might actually use and I was wondering if anyone had some tips on how I could improve it. My code is an auto-clicker that uses Python3 ctypes for the clicking and ...
6
votes
2answers
101 views

1-player Battleship game - follow-up

This question is a follow-up question of this one. I've learnt a bit more Python since then. I recently came back to making battleships again, and I think I did better. These are the changes I've ...
5
votes
1answer
45 views

Print the list of winter bash 2014 hats as a list of checkboxes in GFM format

In Winter Bash 2014, since there is no easy way to see the hats I'm missing per site, I decided to use Gists for that. A perhaps not so well-known feature of GitHub Flavered Markdown (GFM) format ...
2
votes
2answers
58 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
118 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 ...
5
votes
2answers
27 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
2answers
51 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. ...
6
votes
2answers
57 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 ...
4
votes
4answers
91 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 ...