As of May 31, 2023, we have updated our Code of Conduct.

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

Fixing the endlessly loading devices and printers tray

I work for a service desk in a Windows 7 environment. Recently we have had an issue where (do to an update) when users are attempting to map printers to themselves they are not able to open the ...
13aal's user avatar
  • 812
12 votes
3 answers
12k views

Creating zip but for dictionaries

I found myself needed zip but for dictionaries, and wanted to know if there is any way I can make this shorter and more concise, and/or faster. Also I cannot figure out what the type hinting might be ...
Mark Omo's user avatar
  • 449
8 votes
2 answers
564 views

Class for sorting pool balls

I have written this code for fun. I'd like to hear your suggestions about how to make it more compact and pythonic. ...
Pitto's user avatar
  • 799
4 votes
4 answers
9k views

Convert data into dictionary

I am trying to convert "Random = 1" into dictionary {"Random":1} I tried ...
NGB's user avatar
  • 159
-2 votes
1 answer
307 views

Combination Password Generator [closed]

My goal here is to make a program that makes a list of passwords that has no doubles, making an end result of every combination of passwords in a specific area. ...
Gh0st3rZ_N4ti0N's user avatar
4 votes
1 answer
613 views

Python beginner's tree with unit tests

I have implemented a tree in Python. However, due to my lack of experience with Python, I am not able to judge the overall quality of my code. ...
Boni's user avatar
  • 41
3 votes
3 answers
6k views

Finding the longest palindromic substring

I have the following code that works correctly. I am wondering if there is a simpler way to go about implementing my solution and/or if there is anything that looks non-standard in my code. If anyone ...
Calvin Ellington's user avatar
4 votes
2 answers
687 views

Checking whether any anagram of a string appears within another string

I have the following code that takes a string t and checks to see if any anagram of t is a substring of ...
Calvin Ellington's user avatar
3 votes
1 answer
306 views

Basic automation of SSH tasks in a restricted environment

I'm trying to implement a simple automation solution in a restricted environment. I have actually implemented something but it took a bit longer than I wanted. I want to improve the solution and I'll ...
oblio's user avatar
  • 143
4 votes
1 answer
381 views

Small text-based fight

I plan to flesh this out into a hopefully full 2-3 minute text adventure game, and the most fun part to start with is the combat. The fight function down at the bottom repeats itself quite a bit, ...
Adam Burros's user avatar
5 votes
1 answer
4k views

Applying Laplacian smoothing to vertices in a mesh

I'm totally new in Python and I wrote some code. It is a simple algorithm to smooth objects. I need to find adjacent vertices in mesh and sum their coordinates and after that divide by a number of ...
Pagorek's user avatar
  • 51
3 votes
1 answer
85 views

Group duplicate files (part 3)

This is a continued discussion (from here => Group duplicate files (part 2)) with new code and new thoughts/questions (see special question part for details for new questions), and I decide to make a ...
Lin Ma's user avatar
  • 3,443
3 votes
1 answer
1k views

Find the minimum path sum in a binary tree

I am working on the problem of finding the minimum path sum in a binary tree, and printing the path. The path can be from the root node to any leaf node. Here is my code in Python 2.7. I am looking ...
Lin Ma's user avatar
  • 3,443
5 votes
2 answers
785 views

Zigzag Iterator

I've recently solved the LeetCode's "ZigZag iterator" problem: Given two 1d vectors, implement an iterator to return their elements alternately. For example, given two 1d vectors: ...
alecxe's user avatar
  • 17.2k
4 votes
1 answer
5k views

Fill in the blanks game

So I've coded a fill in the blanks game but my last procedure, play_game() is far too long. Trying to figure out how to divide it into two functions: Initialize ...
P.Lucas's user avatar
  • 41
4 votes
4 answers
4k views

Check if two binary trees are equal

I've recently solved the LeetCode's "Same Tree" problem: Given two binary trees, write a function to check if they are equal or not. Two binary trees are considered equal if they are ...
alecxe's user avatar
  • 17.2k
1 vote
1 answer
114 views

Group duplicate files (part 2)

This is a continued discussion (from here => Group duplicate files) with new code and new thoughts/questions (see special question part for details for new questions), and I decide to make a new post. ...
Lin Ma's user avatar
  • 3,443
3 votes
2 answers
6k views

Python text-based fighting game

I wrote a fighting game. My code is rough. I would appreciate constructive and critical feedback please. The goal is to become a better programmer/developer. (I wrote this using 2 Files - The Main ...
Plue's user avatar
  • 379
5 votes
1 answer
69 views

Pick what maintenance check required for game

I have a Python script that plays Airline Manager 2 (on Facebook) for me. So far it can depart flights and buy fuel when the price is good. I would like the program to also automatically plan ...
DarkMatterMatt's user avatar
4 votes
1 answer
269 views

High execution time to count overlapping substrings

I was doing this HackerRank problem which basically boils down to counting overlapping substrings in a string. I used this solution from StackOverflow to build this program - ...
Sidharth Samant's user avatar
4 votes
1 answer
146 views

Group duplicate files

Here is my source code which group duplicate files together, written in Python 2.7. Any advice on smarter ideas to group duplicate files together more efficient, it will be great. Any general advice ...
Lin Ma's user avatar
  • 3,443
10 votes
1 answer
6k views

Reading and processing histograms stored in ROOT files

The Context My daily workflow largely consists of producing, styling, and circulating plots from a dataset to my advisor and collaborators. We use the C++ framework ROOT to generate and store ...
Sean-Jiun Wang's user avatar
5 votes
1 answer
3k views

A Simple Caesar Cipher in Python

I wrote an encryption/decryption algorithm for the Caesar Cipher. It works fine, but I'm curious if there are any constructive critiques, tips, tricks, comments, or advice anyone may have on how the ...
Plue's user avatar
  • 379
6 votes
2 answers
534 views

A python default dictionary which seamlessly saves to disk

I sometimes do experiments at work and separate the computation and the analysis so I can do the computation on a cluster and the analysis locally and sometimes in a Jupyter notebook. I wrote a class ...
HBeel's user avatar
  • 183
3 votes
2 answers
2k views

Hackerrank Submission Optimisation for Melodious Password

Given question from Hackerrank: a password consists of exactly n lowercase English letters. the password is melodious, meaning that consonants can only be next to ...
Sreetam Das's user avatar
0 votes
1 answer
229 views

Check words in documents

Suppose you have two lists: One is a "dictionary", a list of words The other is "documents", a list of documents (which in turn, are strings) I would check whether a dictionary's word is within a ...
Gabrer's user avatar
  • 141
6 votes
1 answer
213 views

Improving the performance of a webscraper

I have here a modified version of a web scraping code I wrote some weeks back. With some help from this forum, this modified version is faster (at 4secs per iteration) than the earlier version. ...
Nobi's user avatar
  • 227
10 votes
3 answers
6k views

A Simple Rock, Paper, Scissors program

I wrote a rock, paper, scissors program. It works fine, but I'm curious if there are any constructive critiques, tips, tricks, comments, or advice anyone may have on how the code operates, performs, ...
Plue's user avatar
  • 379
3 votes
2 answers
7k views

Pythonic way to count if a value is 'NaN' in a dictionary of dictionaries

I have a dictionary of dictionaries with several values. I want to count all the entries that do not contain 'NaN' (Not a Number in a string). ...
Fran Martinez's user avatar
6 votes
1 answer
476 views

Ackermann function in Python 2.7

I'm relatively new to Python. I just want some constructive feedback on how to improve my code efficiency, style, error handling, etc. In this case, I've programmed the Ackermann function, but it won'...
Plue's user avatar
  • 379
9 votes
1 answer
807 views

Print a nice Latex table from an array of values

To present some results I have had to write a short method to turn an array (a list of lists) into a nice representable LaTex table. It needed to have some nice formatting features and the ...
Graipher's user avatar
  • 40.7k
4 votes
2 answers
666 views

Generate a Bitcoin Address and the Wif from a phrase

Is there a way to speed up my Python code? ...
Simone Romani's user avatar
7 votes
1 answer
366 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 "...
shaggs's user avatar
  • 173
0 votes
1 answer
403 views

Reading and writing configuration file

I am working on my first open source project, and I have read a lot to get the desire coding style and I think I got it. But before go further I want to get reviews about my code. This script is not ...
Strapicarus's user avatar
2 votes
0 answers
141 views

Finding vtkCells in the vicinity of or coinciding with vtkPixels

I am looking to optimize this code. In its current state it is working, however, I am looking to improve it. To represent the situation. I have a vtkPixel (...
Aly Abdelaziz's user avatar
2 votes
2 answers
112 views

Reading a file representing word frequencies in Wikipedia, for clustering analysis

I am writing a system that will run Kmeans to determine the most used words in Wikipedia. I do this by building a core set with streaming data. Wikipedia is 50TB but after a year of processing I was ...
Tony's user avatar
  • 123
8 votes
2 answers
3k views

Robot Framework kickstarter - script to run regression test suites

I currently work as a Junior QA tester for a small software business. Before I joined, they had no automation in place to help assist them. I then got hired and resolved this by implementing Robot ...
Goralight's user avatar
  • 183
4 votes
1 answer
835 views

Jinja2 template loader

I am playing around with building my own back end with python 2.7 and jinja2/cgi. Originally I was defining some of my environment and loader variables at the top but figured this was not the best ...
Mike's user avatar
  • 184
7 votes
1 answer
571 views

Hit the target number

After I played the game "The Mesh" for a while I figured that I wanted to make a solver in Python. See the video on the website for a quick intro, I also explain the rules below. The Mesh ...
Mixopteryx's user avatar
10 votes
1 answer
1k views

Display Sensor Data to Web

Last time I worked on a DHT11 sensor and got a lot of feedback, this time I have added another sensor (the BMP180), stored both of them in MySQL, and am now displaying them to the web. The Raspberry ...
Der Kommissar's user avatar
5 votes
1 answer
1k views

Random MP3 Selector and Player

So, I am either a glutton for punishment, or I have no life, but I wrote a script to answer a question over on Ask Ubuntu as a solution for selecting a random MP3 file in a given directory, and ...
Thomas Ward's user avatar
  • 2,518
1 vote
1 answer
6k views

Cropping faces from images in a directory

I am using the below code for cropping faces from images in a directory ...
Pankaj Jain's user avatar
7 votes
2 answers
12k views

Protocol implementation, TCP, sending images through sockets - follow-up

I would like to ask about your opinion about my code. The idea is simple: I designed my own protocol, where client asks server about the image, and the server sends the image, following the below ...
yak's user avatar
  • 223
10 votes
1 answer
4k views

Network protocol using TCP, sending images through sockets

I would like to ask about your opinion about my code. The idea is simple: I designed my own protocol, where client asks the server about the image, and the server sends the image, following the below ...
yak's user avatar
  • 223
3 votes
0 answers
109 views

Quick select - shuffle to make sorting faster

I'm trying to use shuffle to improve worse case scenario of quick select (e.g. every time, selected pivot value is the largest, so each iteration, only one elements could be removed from judgement). ...
Lin Ma's user avatar
  • 3,443
2 votes
3 answers
5k views

Two ways to randomly shuffle cards

Here are two implementations I wrote to randomly shuffle cards. The first method (shuffle) selects a random card, then swaps it to the front. The second method (<...
Lin Ma's user avatar
  • 3,443
6 votes
1 answer
600 views

Expanding url from shortened url obtained from tweet

I have a twitter data set. I have extracted all the expanded urls from the json and now am trying to resolve the shortened ones. Also, I need to check which urls are still working and only keep those. ...
mlearner's user avatar
8 votes
2 answers
151 views

Developing an investment strategy based on stock movements

Below is my code ...
Pankaj Jain's user avatar
14 votes
4 answers
3k views

Reading a DHT11 to a file

Disclaimer: not a Pythonista, first actual Python programme written right here. I'm reading a DHT11 sensor from GPIO pin 4 on my Raspberry Pi (thanks Thomas Ward for sending the RPi to me), and I ...
Der Kommissar's user avatar
5 votes
1 answer
76 views

Python with alternative keywords - follow-up

Original post here. I've taken @ThomasWard's advice, and also added a couple other things. ...
user avatar

1
5 6
7
8 9
25