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.
1,231 questions
1vote
1answer
110views
Database design using Closure Table for tagging system
I created these database tables with the inspiration in NjDevPro github repository. The design uses Closure Table for implementation of hierarchical tagging system in ...
3votes
2answers
305views
JSON Lexer code
How does the following look for a json lexer? Are there any things that can be improved upon? Does the pattern look general-purpose enough to be able to generalize it to make it into a useful program, ...
1vote
1answer
2kviews
Function to add a new key pair value to my JSON file
As you can see I am using a counter variable to iterate through my JSON file and it's a dictionary that has a list of dictionaries. Once I find the key normalHours I divide it and add it to my ...
1vote
1answer
141views
Register/Login for Rock/Paper/Scissors
Recently I have been learning Python after years of putting it off, and I am having a really fun time with it. However after I spent a few hours making something that I thought was pretty cool, I ...
1vote
1answer
209views
Loop through polyline vertices and update coordinate
I have a Python 2.7 script that loops through GIS polylines and updates a coordinate. The coordinate is called an "M" coordinate (aka a "Measure-value"). M coordinates are similar ...
1vote
1answer
74views
Checks for removing files after X amount of days
I am trying to remove files in my directory if they are over 30 days. However, I don't know what other checks I need to do. The examples I found online weren't very thorough besides just subtracting ...
1vote
1answer
3kviews
What is the pythonic way to update my nested dictionary?
So I need to update my nested dictionary where the key is "compensationsDeltaEmployee". I created a string cost_perhour to hold the value of my conditional statements. Now that I am done ...
1vote
2answers
1kviews
Is there a faster way to write dictionary values to csv?
I have a dictionary that I am writing to a csv file, however I am only writing the values. I want to know if there is a faster way than using a for loop. I am using python 2.7 here is my code. ...
3votes
4answers
2kviews
Find differences between two directories
Coming from another language than Python, I would like to see if my code is "pythonic" enough and follows good practices. It compares two directories, showing all files that are in one and ...
8votes
3answers
3kviews
Calculate evapotranspiration
I am trying to create a code for the Basic evapotranspiration equation by Hargreaves. I have attached a screenshot of the equation to be replicated. I want to create a class wherein I can input data ...
5votes
1answer
1kviews
Send email with attachments, including in memory zipped attachments
The below class implementing a simple way to create emails with attachments, including the option to create in-memory zip files and attach them to the email. Because I am not a professional programmer ...
8votes
2answers
3kviews
log setup using RotatingFileHandler and basicConfig
I am new to python, and developing a moderate application for which I need to setup a logging mechanism. The below program sets up log handling, which gives the user an option to specify whether log ...
3votes
1answer
65views
Interactive, real-time bikeshare web application with Bokeh
As a side project, I'm working on a Bokeh web application to display public bikeshare data on a map. The data is updated every 2 minutes using a periodic callback. Below is the full implementation. I'...
3votes
0answers
60views
Python script that getting list of all files with specific ext starting from the current folder. Using timer for reporting about the process
I am using a function that returns a list of all files (full path for each of them) with the given extension in the given folder and all subfolders. As the process is quite long and user can get ...
2votes
3answers
614views
Bifurcating recursive calculation with redundant calculations
def T(n): if n <= 0: return 1 else: return T(n-1) + (n-1) * T(n-2) print T(4) I need an effective way to print out the output of the function <...