Python is an interpreted, general-purpose high-level programming language whose design philosophy emphasizes code readability.
3
votes
1answer
10 views
Entry filter for list of directories
I'm trying to filter a list composed of multiple dictionaries for useless entries and non-ideal fields. An entry is useless if Mem['visibility'] == "redacted" and ...
0
votes
1answer
12 views
Caesar Encryption-Decryption Tool
I'm a beginner in Python.I wrote this code which encrypts and decrypts text using Caesar chipher.I wrote it in many days and optimized it manytimes.But how it can be improved more?
Notes:
*I've ...
3
votes
3answers
50 views
Using argparse with parameters defined in config file
I understand that and why using eval is generally considered bad practice in most cases (see e.g. here). Related questions on config files and argparse don't use ...
3
votes
1answer
17 views
Find all distinct palindromic sub-strings for a given string
I was solving a question where I had to find all possible unique palindromes of a string.
I was able to come up with the solution shown below. If I am not mistaken it is an \$O(n^2)\$ solution. I'd ...
3
votes
1answer
22 views
Collatz Sequence in Python
I'm trying to use Python to solve the Project Euler problem regarding the Collatz sequence. With some research online, I have come up with the code below. However, it still takes a long time to find ...
2
votes
1answer
23 views
“back substitution” method for solving linear system
I'm using numpy to write the "back substitution" method for solving linear system where "A" is a nonsingular upper triangular matrix.
...
2
votes
3answers
35 views
Calculator using Tkinter
So this is my first project.
I made a Calculator using Tkinter.
For the next version, I will try adding
oops concepts
Custom parser for input
Here's the code
...
8
votes
3answers
759 views
Password Strength Detector
I'm just a beginner in Python.I wrote a simple code that detects the user's password strength,but I feel that it isn't very efficient.How can I improve it?
...
-1
votes
0answers
13 views
(Guessing game) How to progress level by level? [on hold]
So I recently created this guessing game which works like it is, but I wanted to make a way were the user can't progress to the next level without completing the previous level. So far I have it in ...
2
votes
1answer
32 views
Parse Twine HTML to JSON
For those who don't know, Twine is just a simple interactive fiction making tool. It lets you easily create a series of passages that are hyperlinked to each other, making a choose your own adventure ...
3
votes
1answer
29 views
Looking up alias using inspect in Python
I'm on a quest for making a good debug_print() method for printing out debug information in some of my private projects. When testing I aliased my ...
0
votes
2answers
60 views
Python 2.7 Payroll Calculator program
This is a calculator I'm working on. The ultimate goal is to calculate multiple payrolls before selecting to end the program, please review current version in that context. PSA: I'm a beginner.
...
3
votes
2answers
31 views
Clone and replace attributes that are instances of a specific class
For a given object that may be an instance of a class, a built-in container or type, I would like to copy that object, but replace all instances of a given class with something else. I can do this ...
-2
votes
0answers
42 views
Python operating system [on hold]
I have been working on a Python OS in the shell and I am now trying to figure out what to add to it. If you run it, it works fine. I am just wanting your opinions on what you think I should include.
...
5
votes
1answer
67 views
Game of Life in Python 2.7.10
Conway's Game of Life is a common problem. I had to write a version of it to get my current C# job, so I thought it would be a nice way to get into Python (especially as the example in the book are a ...
3
votes
1answer
43 views
Battle simulator RPG
I just learned about classes today and wanted to find a way to implement them that interested me. I whipped up this little battle simulator and would like any feedback and critiques as well as any ...
2
votes
1answer
21 views
Send emails with data from spreadsheet files
I wrote a tool to send emails with data saved in excel spreadsheets (.xlsx).
It uses the openpyxl module to interact with the spreadsheets and smtplib to send the mails.
It is only tested with (and ...
4
votes
3answers
52 views
'Learn projects the hard way': logfind project
I'm a new programmer, who has just finished his first small project.
It's a sort of basic imitation of the grep command from Linux. I'm learning from projects the ...
4
votes
3answers
60 views
Rock Paper Scissors with scores and save file
I've implemented the classic game Rock Paper Scissors with scores, and a save file implementation. I'm looking particularly for ways to get rid of all the self.'s. ...
3
votes
3answers
60 views
Genetic search algorithm for TSP
I made a genetic search algorithm in Python for the Travelling Salesman Problem for a midterm project. The grade was fine, but I was hoping to get some pointers on style and documentation. Please ...
4
votes
3answers
98 views
Python script to delete sections of text
I've been writing a python script to help me clear up some files that contain outdated code, while also serving as a way to learn python. These files have sections of code surrounded with tags on ...
1
vote
0answers
36 views
Random Contraction Min Cut (Karger) - performance issues
(Offtopic note: I can't add a "networkx" tag.)
I reworked an old algorithm, this time not implementing the graph on my own, but building on the networkx module.
Script works fine for the tests and ...
1
vote
3answers
109 views
Finding Egyptian fractions with A* search
I've written an A* search to find the optimal solution to the equation
$$ \dfrac{4}{n} = \dfrac{1}{x} + \dfrac{1}{y} + \dfrac{1}{z} $$
with \$n, x, y, z\$ positive integers, and \$n\$ given; the ...
4
votes
3answers
56 views
The Odd-Even Challenge
After posting my first question on here, I got a lot of great feedback. I've decided to try another challenge and write it as cleanly as possible.
The rules of Odd-Even consists of the following ...
1
vote
2answers
56 views
7
votes
1answer
66 views
Simple Python 3 templating module
The module adds syntactic sugar to Python 3 to allow concise specification of templates. I use it to generate a collection of static web pages from various data sources.
I wanted something ...
8
votes
2answers
57 views
Yet another lightweight Enum for Python 2.7
I'm trying to develop a lightweight enum for Python 2.7. This question is downstream of the SO question here; for context, a streamlined version of the bulleted addendum to that question is ...
6
votes
4answers
2k views
FizzBuzz in Python using a class
I recently read the book clean code by Robert C. Martin and I'm trying to apply his style of writing methods to the FizzBuzz programming example.
So far I have two "public" methods called: ...
1
vote
1answer
50 views
Latent Dirichlet Allocation in Python
I've recently finished writing a "simple-as-possible" LDA code in Python.
The theory from which I've developed my code can be found in the book Computer Vision by Simon Prince, free (courtesy of ...
5
votes
2answers
140 views
3
votes
1answer
52 views
Longest palindromic subsequence by memoization
I've written some code to solve the longest palindromic subsequence problem.
...
2
votes
1answer
109 views
Highest floor of a building from which to drop an egg without breaking it
Problem description:
You have two eggs, and need to find the maximum floor of a 100-floor building from which you can drop the eggs without them breaking. Do this with as few attempts as possible. ...
3
votes
2answers
37 views
Writing embedded list to CSV in Python
I have a method in a Python app to write a list of records to a CSV file. Each record is a "football player", which is really just a dictionary. But one of the dictionary items contains a list of ...
4
votes
3answers
61 views
Alberi puzzle creator - follow-up
This is a follow-up to this question.
Using his ExactCover class, I slightly modified Garth Rees' Alberi class to cope with ...
3
votes
1answer
53 views
“Day-of-the-week-finder”
I'm new to Python/Programming and wrote this simple "Day of the week/Holiday finder" script. Ideally I'd use something so I can have a little widget on my desktop, but right now I'm looking for any ...
2
votes
1answer
44 views
1
vote
0answers
23 views
Abstracting away implementation details of my rethinkdb Model class
I have a module called db, which looks like this (shortened):
...
3
votes
2answers
68 views
Find first unique char in string
I intentionally avoided Python tools which would make this even more trivial. I would like to be reviewed on efficiency, style, and obviously if there is a bug I would like to know.
...
2
votes
1answer
53 views
Find 3 elements that sum to zero in an int array
Find 3 elements that sum to zero in an int array.. I would like to be reviewed on efficiency, style, and obviously if there is a bug I would like to know.
...
9
votes
3answers
500 views
Push all zeros to tail of int array
My script pushes zeros to end of an int array. I'd like to be reviewed on efficiency, style, and obviously if there is a bug I would like to know.
...
4
votes
1answer
37 views
Find an array slice equaling sum
I would like to be reviewed on efficiency, style, and obviously if there is a bug I would like to know.
...
2
votes
1answer
47 views
Applying a formula to 2D numpy arrays row-wise
The user has two 2D input arrays A and B, and a given matrix S. He wants to apply a
...
3
votes
0answers
35 views
Simple Python plugin loader
I have written a simple system to load plugins from files in Python 2.7, and I'd like to see if any of it can be improved upon.
vedo.py
...
3
votes
2answers
35 views
SOAP request in a while loop
I am developing a service where the user need to sign the seller agreement with Mobile BankID (Swedish e-sign service). To make this work I need to make SOAP request to get the progress status of the ...
2
votes
1answer
33 views
Extracting an arbitrary element from each row of a np.array
I have a large numpy array of shape (n,m). I need to extract one element from each row, and I have another array of shape (n,) that gives the column index of the element I need. The following code ...
3
votes
2answers
55 views
TDD Hackerrank: Library Fines
From this hackerrank:
Problem Statement
The Head Librarian at a library wants you to make a program that
calculates the fine for returning the book after the return date. You
are given ...
4
votes
2answers
38 views
Watch a directory and insert new entries into database - Follow up
This is now my new code implementing the recommendations from my previous question.
...
1
vote
2answers
26 views
Get list of indices from searching for values in list of lists
I have a list of lists of numbers. The numbers are in sequential order, ranging from 0 to n and each number only appears once. I want to loop over all the numbers in the list of lists and return the ...
3
votes
1answer
55 views
Checking for hyperthreading
I want to just write a simple function to check if my linux box has hyperthreading enabled. I want to know if there's a simpler way to produce the cpuinfo dict ...
4
votes
2answers
42 views
Multiplication Grid function
I've made a small function to output a multiplication grid (those things from primary school! :P) to an inputted number.
...