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
7
votes
1answer
234 views

Raster processing for climate change model

I am working on a project on how climate change may affect the development of spruce budworm larvae throughout each year (historical and projected) using different climate change models and emission ...
4
votes
1answer
75 views

Downloading 2 tables from db, does calculation and uploads resulting table

I have written this script that downloads two tables from the db, preforms an intersection on them and adds 2 new columns to the resulting table, and uploads the resulting table to the db. It's a bit ...
2
votes
1answer
287 views

Arcpy script to check for TIFF files and add them to different lists

My script goes through sub folders in my main directory and based on a wildcard checks if a tiff file exists or not, if it exists then the file path is appended to the corresponding list. For example, ...
1
vote
1answer
83 views

File names to database table

I have files in subfolders on a network drive. I want to create a list of files, and insert that list into an Oracle table. I can successfully iterate through the files in the subfolders and do the ...
3
votes
1answer
130 views

ArcPy script to analyze land use in counties

We have written a Python script using arcpy modules. It is was written by Python beginners and many parts of the code are written in 'unpythonic way'. The goal is ...
1
vote
2answers
191 views

Updating ArcPy feature classes

I am looking for the way to speed up my script. The final output is as required, but it's clunky and really slow. I know it's slow because of the double for..in.. ...
2
votes
0answers
32 views

MinMax product for large matrices

I created this program which runs with no error, but I'd like to have some comments if it is possible to optimize it, since I need to run the program with N = 3200. ...
9
votes
3answers
3k views

Bulls and Cows in Python

I have recently written this little Bulls and Cows game in Python: ...
3
votes
1answer
369 views

One minute cron Python script reads from MySQL and updates Redis based on calculations

The following code works and will be put into cron on a AWS server (not sure what specifications, cores, kernels etc) at a every 1 minute frequency. However, it's my first time putting a script into ...
1
vote
1answer
62 views

Replace characters using multiple dependent regular expression substitutions

I've written the following Python module to iterate over field values in the following two fields: "NAME_LABEL", "CATEGORY". I'm using regular expressions in the following function: "...
2
votes
2answers
1k views

Sorting two related lists

I have code that sorts two lists related with each other ...
0
votes
1answer
71 views

Python Readability for SQL query [closed]

I have this piece of code in Python 2.7: As you can see is very hard to read the SQL query, what is the best way to re-write it? ...
5
votes
1answer
2k views

“Heads or Tails?” guessing game in Python

I'm pretty new to coding and I want to get an opinion on my coding. I am learning Python and I made a really simple heads and tails guessing game. ...
3
votes
0answers
219 views

OLED display application for Raspberry Pi

Python script to output status information to a small OLED screen connected to a Raspberry Pi. I'm relatively new at writing python so although the app works and outputs correct information it is far ...
2
votes
1answer
42 views

Looping text in Python with directional control

The code is an implementation of looping text (similar to a circular buffer - wraps around when it reaches the edge of the defined bounds) with directional control. The code is functional and works ...
7
votes
1answer
264 views

Python siren control

Below is some code I've put together to contol a siren for a fire service. It works by webscraping a paging feed and looks for set triggers. Is there a better way of doing my code or is this "...
7
votes
4answers
44k views

Count occurrence of words in a .txt file

I'm taking an intro to programming class and although I've learned some things I didn't know before (I've been using Python for about 1.5 years) I feel like I've not progressed much in writing "...
5
votes
1answer
208 views

Using range minimal query for lowest common ancestor (LCA) — part 2

Here is my code to use range minimal query to resolve the LCA problem. I applied comments from here. Any advice on code bugs, performance improvement in terms of algorithm time complexity, code style ...
-1
votes
1answer
179 views

Decoding a string encoded by Caesar Cipher and some delimiters [closed]

I have the following code which I seek to optimize. The result of the bruteforce I already have but I'm just trying to learn some more python using the same example. The code in the data needs to be ...
8
votes
2answers
3k views

Printing letters in order like a pyramid

There is this hackerrank question, where we need a rhombus of letters. As to my opinion it can be viewed as some fractal, or similar logic. Well I solved the question, but I am obviously disappointed ...
2
votes
3answers
135 views

Code to find the sum of the product of all size-n combinations of an array

The title is a bit of a mouthful, so here's a quick example: You've got an array, maybe just the digits 1-3, and you want to get the sum of product of all size-2 combinations of the array. Those ...
0
votes
1answer
69 views

Printing all the factors as well as the prime factors of a given number using Python 2.7.x

Okay here is my maiden attempt at programming using Python 2.7. I need help or feedback on this code: How do I know about the processing cycles this program consumes? How do I implement this idea ...
3
votes
3answers
197 views

Function to test for different conditions in input data

I have the following function that checks a data record to see if it has met certain criteria specified separately in configuration settings. The configurations are set up as a list of dictionaries ...
7
votes
1answer
378 views

Printing factors and prime factors of a number

I am a 46 year young newbie trying to learn programming for fun and adventure. I do this in my free time. Some very nice gentlemen on stackoverflow have sent me here. I wish that someone could review ...
6
votes
1answer
630 views

Printing bowTie pattern in efficient and pythonic way

I've posted code/library to GitHub for first time over here. The code is pretty simple. It generates a BowTie pattern of given size and characters. I did attempt to implement DP by calculating only ...
2
votes
1answer
90 views
3
votes
2answers
995 views

Python 2.7 Powerball Game

This game allows one to either pick their own lottery numbers or have them generated and checks them with the most recent numbers, jackpot, and multiplier. I use concepts such as ...
6
votes
1answer
202 views

Simple CLI Python Hangman game

Preamble: I am very new to Python, and outside of Googling functions and a former work colleague telling me why I'm wrong, I have no formal training and haven't taken any "Learn Python" courses. I ...
5
votes
1answer
10k views

Python internet speed testing

I understand there are a few similar tools available for testing speed but that's not what I'm looking for. I'm looking at seeing how long it takes to request a site's HTML. However, I'm getting ...
4
votes
1answer
14k views

Sorting two lists

This sorts two lists (a, b) according to aand returns two sorted lists separately: ...
1
vote
1answer
5k views

“Flipping bits” Python implementation

Problem Statement You will be given a list of 32 bits unsigned integers. You are required to output the list of the unsigned integers you get by flipping bits in its binary representation (i.e. ...
1
vote
1answer
62 views

Executing a function's flow

My __main__.py file has a function's flow, based on methods of each class instance, which each one has its own methods and attributes, like this: ...
2
votes
2answers
453 views

Decompress files files in a directory recursively

Currently I'm trying to redo this code to avoid the breaking line because of the 80 characters rule: ...
3
votes
1answer
7k views

Fast loop to create an array of values [closed]

I have a code that creates a 3D array of values from a minimum to a maximum in X and Z with constant Y. Right now I make it in normal Python, and then I transform it in a ...
2
votes
2answers
216 views

Classifying files in a directory by file extension

I have the following code: ...
5
votes
3answers
6k views

Transforming tuple with (int month, int year) in string “mm/yyyy”

I would like to improve the following code: ...
5
votes
1answer
907 views

Edit configuration files script

Script designed to avoid manually edit configuration files by support. Config file example: ...
6
votes
1answer
196 views

Container (dict preserving key order, with attribute access)

This class is part of the Construct library. Container is a dict that: turns attribute access into key access so ...
1
vote
1answer
1k views

Uploading and downloading files with FTP

I'm learning Python and decided to rewrite my FTP tool from Perl to Python. The program is able to up/download files, change the directory and list the files of the current directory. Is there ...
2
votes
0answers
165 views

Generate similar methods programmatically [closed]

I'm repeatedly faced with writing proxy classes for various purposes, recently lazy evaluation and IPC. This usually means having a single method pattern, which just forwards the call. I'm having a ...
5
votes
1answer
233 views

AIO programming challenge - Friendlist - Who has the most friends?

I attempted this sample question from the Australia Infomatics Competition. TL;DR - Each line of input contains two numbers, representing a mutual friendship relationship. The output needs to be the ...
0
votes
1answer
112 views

Parsing Python arguments

I'm trying to cover the following 4 scenarios: No parameters DB param DB param and 1 option No DB param and 1 option So far I have the program working for all scenarios. However, I'm not happy with ...
2
votes
3answers
234 views

isPrime functions in Python and Java

This Python code looks messy to me. Am I doing any wrong style, or is this how Python looks like? ...
9
votes
1answer
4k views

Learn Python the Hard Way #48 — lexicon exercise

I'm trying to get some feedback on my code for the lexicon exercise (#48) in Learn Python the Hard Way. I have only recently started learning Python and want to make sure I have my fundamentals down ...
10
votes
3answers
2k views

Stack Overflow user info fetcher

I'm starting to look at Python and its facilities. I've just tried to make one simple program using some base libraries. I would like to hear some comments about anything you've noticed - style, ...
8
votes
3answers
29k 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. ...
11
votes
1answer
1k views

Poor man's f-strings in Python 2.6

f-strings is a new feature in the upcoming python release which basically lets you do this: >>> s = 'qwerty' >>> f'{s} {1+2}' 'qwerty 3' Not ...
3
votes
2answers
7k 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. ...
5
votes
3answers
343 views

Python lexicon class

First time around Code Review so please be gentle (and I am happy for comments on which angles of this post are a good fit and which less so). I'm not pretty much used to software engineering in ...

1 2 3
4
5
25