We’re rewarding the question askers & reputations are being recalculated! Read more.

Questions tagged [python-2.x]

Python 2 is the predecessor of Python 3 and its last version, Python 2.7 was formally released on July 3, 2010. Use this tag along with the main python tag to denote programs that are meant to be run on a Python 2 interpreter only. Do not mix this tag with the python-3.x tag.

Filter by
Sorted by
Tagged with
3
votes
5answers
115 views

Product iteration while checking for overlaps

This is an extended question to the following question I posted Class scheduling tool with image output Context of previous question: I have a multilayered dictionary that contains information ...
3
votes
1answer
382 views

Using os.path.join in Python

I want to reduce/shorten this part quite a lot. If you see that a method can be reduced or even erased please do not hesitate to suggest that. Any answer that rescue the code would be great. ...
6
votes
1answer
128 views

Simple application in Python using OpenCV for face

I have been working on a simple Python application for face recognition with OpenCV. My code does its work and gets the job done, but I'm wondering if there's a 'better' way to do this. I hope I can ...
5
votes
3answers
939 views

WV lottery tool in Python

I am self taught in python. I love to play the lottery and play with numbers. I put this program together as a hobby to learn python and build something that people can use. I used and reused code ...
4
votes
2answers
137 views

File's encryption tool in terminal

I've created a wrapper for the SimpleCrypt library that allows to easily encrypt/decrypt a string. The application is used this : ...
6
votes
3answers
226 views

Class scheduling tool with image output

I have a multilayered dictionary that contains information about classes. I am using this to code an automatic schedule builder that I will eventually add to a separate Tkinter application I made that ...
4
votes
1answer
390 views

Console Tic Tac Toe

So I started Python this week, and I never programmed a game before. Even though Tic Tac Toe is probably the simplest game ever, I had some challenges while coding the game rules. I split my project ...
7
votes
1answer
183 views

Dynamic Programming with Project Euler problem 67

I am a beginner with python and programming in general. I started teaching myself about 2 months ago. I've been working my way through Project Euler and a few similar sites to build my chops, and ...
1
vote
3answers
1k views

Simple Blackjack game in Python 2.6.9

Like the title says, I made a very simple game of Blackjack using Python version 2.6.9. I am relatively new to python and programming so I would really appreciate some constructive criticism to help ...
3
votes
1answer
166 views

My images have secrets A.K.A. the making of aesthetic passwords V.2

This is my implementation of a prng steganography tool written in Python. You can also find the code on GitHub. Steganography is the art of hiding messages in (images, videos or even audio) I've ...
8
votes
2answers
6k views

Python code that compares two files byte by byte

I wrote a Python (2.7) script that compares a file byte by byte. filecmp was not suitable for the application because it compares metadata as well. How can I ...
13
votes
1answer
15k views

Decorator to measure execution time of a function

This decorator adds the elapsed time to a function's attributes when applied. My concerns: Is the code pythonic? Could this code be useful? Should I just use the ...
1
vote
0answers
218 views

Cellular Automata: Counting preimages

One of the Google Foobar challenges requires you to write a program to count the the number of preimages of a position in a 2D cellular automaton, under the following rules: You find that the ...
2
votes
1answer
240 views

Reverse shell allows connection between computers

I've recently made a reverse-shell which allows you remote shell access to other computers. It's written in Python 2 and it is cross-platform. Basically, it get's user input for a command and sends ...
25
votes
4answers
11k views

Validating Credit Card Numbers

This is one of the puzzles I was trying to solve, where the question is to validate the credit card number with following characteristics: It must contain exactly 16 digits. It must start ...
13
votes
2answers
478 views

A classy DNA nucleobase counter

This question is part of a series solving the Rosalind challenges. For the previous question in this series, see Counting nucleobases in a nucleotide c. The repository with all my up-to-date solutions ...
3
votes
1answer
1k views

Download and write ~100k images

Currently I will be downloading around ~100K images. This process may run on a weekly basis, I'm considering the following factors: HTTP Requests (Will be taken care by external LB, so same source IP ...
2
votes
1answer
542 views

Python Merge Sort Implementation

I doing some algorithm reviews and am soliciting opinions on my implementation of the Merge Sort in Python. Anything from readability to optimization is fair game. In particular, I am wondering if ...
4
votes
1answer
2k views

Splitting up a list with datetimes

I have this ordered list of datetimes that comprises of 30 minute slots: ...
4
votes
2answers
429 views

Encoding and Decoding In Python

My script encodes text and outputs random strings. It is different each time and loads a dictionary that has been pre-set by my dictionary gen.py (included after the main script). I've started my ...
4
votes
3answers
647 views

Simple RSS to HTML converter

Is this code pythonic, easy to read, stable, or missing something? ...
9
votes
3answers
3k views

Dictionary of dictionary - Get 2nd keys

I have a dictionary of dictionary such as d below, and I would like to get the list of all keys but not on the first level (i.e. ...
8
votes
3answers
24k views

Downloading images from URLs

I'm just beginning with Python and programming, so been trying to get as much experience reading code as possible. The script mentioned below do grab images from URLs and put them in into a folder. ...
5
votes
1answer
128 views

Using NumPy to scale data in 2 out of 3 columns

The below code takes a csv containing age, weight, height and prints the betas determined through linear regression to an output csv. It runs for 10 iterations using a different alpha for each, and ...
2
votes
2answers
9k views

Using BFS to solve 8-puzzle game using Python 2

I'm trying to solve the 8-puzzle game using BFS, DFS and A* algorithms implemented using Python 2.7. For now, I have managed to solve a couple of test cases using BFS and I want to know how I can ...
8
votes
1answer
902 views

Black Jack Game in Python (Jupyter)

I am working on Jupyter Notebook and I am new to Python. I have created this BlackJack Game (This is my 2nd Project as I am Learning Python. See my 1st - Tic Tac Toe ...
6
votes
1answer
315 views

First time using Tkinter

This is my first time using Tkinter and really trying to get use to using classes in Python. I wonder if I'm using self entirely too much, but here is my code: ...
3
votes
2answers
6k views

Text based survival game

I have recently made a text based survival game. I hope that I can improve the game but I am not sure where I can improve it. It is NOT EASY, don't expect to get over it the first time. ...
15
votes
3answers
773 views

My images have secrets A.K.A. the making of aesthetic passwords

This is my implementation of a prng steganography tool written in Python. You can also find the code on GitHub. Steganography is the art of hiding messages in (images, videos or even audio) I've ...
2
votes
0answers
41 views

Algorithm for point distribution of traversal between 2 points on a line in time

Not sure if this is best SO forum to post at, please suggest/move to more appropriate place otherwise. A synopsis of the problem 1st: Given a scenario where we have messages with data that define a ...
4
votes
1answer
231 views

Aggregating text and deleting duplicates with pandas to consolidate a table for reporting

At work, I use software for analyzing administrative data and daily I generate a CSV that looks like: ...
4
votes
1answer
929 views

Implement a boto3 RDS generator in Python

Boto3 does not seem to implement a generator for RDS instances, instead offering a marker and pagination feature. This code does work for my use case and I have been using it for the entire day ...
7
votes
1answer
2k views

Tic Tac Toe in Python (Jupyter)

I am working on Jupyter Notebook and I am new to Python. I have created this tic tac toe game. ...
14
votes
4answers
1k views

Codechef: Prime Number Generator

Peter wants to generate some prime numbers for his cryptosystem. Help him! Your task is to generate all prime numbers between two given numbers! Input The input begins with the number t ...
6
votes
0answers
286 views

Simple AR Tag classifier

I have been working on creating a simple AR Tag classifier, for detecting a simple AR Tag glyph. Spitting out an image that looks like this: With the red circle indicating the corner closest to the ...
7
votes
2answers
512 views

Recursive function and memorization to find minimum operations to transform n to 1

I'm a new, self-taught programmer working on the Google FooBar challenge. I've submitted my answer (code at bottom) and it was accepted, but I'd like suggestions on how to improve my solution. ...
27
votes
2answers
25k views

Password checker in Python

Using Python 2.7.12 I wrote a simple little script, psk_validate.py, that prompts the user for a potential password and checks if it has upper and lower-case ...
8
votes
1answer
136 views

Creating strings of desired length from a list of substrings

I have a method that generates strings from a list of substrings, and the desired length of all these strings is passed as an argument of the method. Here is my code: ...
3
votes
2answers
812 views

Random Password Generator based on user input

This is my second program written in python. It basically creates a password made up of numbers, capital and lower case letters with the option to include special characters and dashes. I created a ...
4
votes
1answer
115 views

Looping through multiple breadth first search test cases

I'm a new and self-taught Python programmer. I've been working my way through the Google FooBar challenges and wrote the following for the prepare_the_bunnies_escape challenge. I submitted the code ...
5
votes
2answers
1k views

Validation methods to ensure start and end date come after existing instances

We have a "Committee" class and I need to ensure that any new committee has start and end dates (don't know why they're CharFields instead of Dates or even Ints, but that's not my call) that are after ...
3
votes
1answer
1k views

Django REST Framework - PDF Generator

I created a new endpoint for an API (Django REST Framework) that generates a PDF from an HTML template. I follow the example from the plugin django-easy-pdf. It's working, but I would like to improve ...
8
votes
1answer
251 views

Kernel Convolution in Python 2.7

The code I wrote performs a mean blur on an image (I hardcoded it as zebra.jpg for testing purposes). My problem is that for an image of 39KB image it take minutes to perform, is there any way of ...
2
votes
1answer
2k views

matplotlib get_legend_handles_labels always return empty

I have a problem when adding elements to the same figure. The problem is with the legend. At each iteration I add elements and the corresponding legend. But I want the legend to include all the ...
4
votes
1answer
3k views

Using Python to remove blank lines and comments in Assembly code

I made this little script to help a friend. He studies computer engineering and is doing a project where he has to make assembly files with comments and some formatting for presentation, but, as he is ...
1
vote
0answers
23 views

QtGui interface - improvements to structure

My code brings up a GUI interface, the user enters info: text that ends up in the resulting report, and dialog windows that select a file, be it data or a picture. I have been using this code ...
4
votes
1answer
2k views

Select value based on condition on dataframe

I have some data in data frame and would like to return a value based on specific conditions. It is highly time consuming. I tried three methods: Method 1: Without dataframe, this is the simple ...
4
votes
1answer
562 views

Creates a maze from file and enable user to go trough it with graphic display

I'm following the learnpythonthehardway.org book for learning Python. I recently made a one week projet and as I'm fairly new to coding program with POO and multiple files, I'd like to have someone ...
7
votes
2answers
4k views

Using python and beautifulsoup to iterate through a list of websites to find a particular string

I'm attempting to find companies who mention a particular service in on their homepage. To do this, I am iterating through a csv file with two columns - ID and URL. I'm using BeautifulSoup to get the ...
3
votes
1answer
163 views

Python CGI front-end for web service to perform machine translation

I am trying to optimize this python script that is used to process web requests for machine translation. The actual translation executable that is called is quite fast. Also, the perl scripts that are ...