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.

77 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
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 ...
5
votes
1answer
75 views

Sorting software version list using Python 2.7 (no modules)

I am participating in a challenge and one of the challenges was to write a script to sort a list of software versions (ex: 1.0, 1.3.2, 12, 1.3.0). Here is the my solution: ...
5
votes
0answers
180 views

Code for training machine learning linear regression and SVM

Ok , for my final year project I've wrote this piece of code to train my machine learning model on a this dataset , here the code i used ...
5
votes
0answers
689 views

Simulate object.__getattribute__ in Python

I want a Python example that illustrates how object.__getattribute__ resolves instance attribute lookups. I'm looking for feedback about the following code. Is it ...
4
votes
0answers
45 views

Python Project Template

What's up smart people. A little backstory for context: I'm a completely self taught dev, and the only person ever looking at my code for the past 6 years is myself. I realize that's not the best idea ...
4
votes
0answers
34 views

Combining CSV files of simulation results

This script is a subset of a larger script where I have the output of many test simulations in the form of CSVs. Each file starts with the model name and includes the number of elements in my file. ...
4
votes
0answers
53 views

Improving SVM fitting accuracy

I have this attempt on classifying CIFAR10 images. I'm curently training my SVM only on 1 of 5 sets, and decided on using polynomial kernel(degree=3,C=0.1 [changes have no effect],gamma=2 [changes ...
4
votes
0answers
855 views

subprocess with logging module: tee with StringIO

I've got a long-running process. Once it finishes I need the output. But the user should be informed while it's running. With the logging module I get timestamps ...
4
votes
0answers
703 views

Script that reads data over usb from Arduino to RaspberryPi, cleans it up and publishes to an MQTT broker

This is a continuation from this question: Reading analog moisture signal from Arduino over USB to RPi3 and publishing via paho MQTT I made the advised changes, and added a bunch of new stuff, I'd ...
3
votes
0answers
61 views

Animation of an incremental rotary encoder

While reworking my teaching materials for an exercise of an introductory course on mobile robotics, I recently created a animation/simulation of an incremental rotary encoder, e.g. often used for ...
3
votes
0answers
56 views

Pygame : processing speed independant image loop displayer

I made this in order to teach myself pygame. This displays an images loop at the same speed on any computer (It will lag on a slow computer). Is my time management good or do my datetime call could ...
3
votes
0answers
89 views

Python Type System

Problem Statement: I am writing Job Scheduling software in Python. I expect users of this software to provide Job definition in XML like format. For example: ...
3
votes
0answers
133 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 ...
3
votes
0answers
55 views

code for changing from old copyright to a new one in python

This code needs to get two inputs: one is the full address of a directory and another the file extension that it will be changed. These inputs cab be added in the default section of ...
3
votes
0answers
379 views

PyCrypto AES-CFB with SCrypt and HMAC

I am brushing up on my Python, and since I would like to learn a bit about encryption, I figured I would give PyCrypto a try. I obviously wouldn't implement encryption in any production environment, ...
3
votes
0answers
90 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). ...
3
votes
0answers
630 views

Thread-safe RLockedList

I have written a thread-safe list which can be used as a drop-in replacement for a regular list. This has been tested and used internally without issue, but "The absence of evidence is not evidence of ...
3
votes
0answers
584 views

Counting squares in a grid that is subdivided by line segments

Problem: Given a picture of square with a bunch of horizontal and vertical lines in it (lines are not necessarily spanning the full square length, in other words think of a fine grid with many ...
3
votes
0answers
437 views

Touchscreen Right Click

I have built a small script that provides touch screen right click context menu with long touch press in my ELAN touchscreen. There is no need to remove your finger in order context menu to pop up. ...
3
votes
0answers
615 views

RC Plane Radio using the Raspberry Pi

This python code is for a homemade RC plane radio using the Raspberry Pi and a USB joystick. It sends values over serial to DSM2/X module for RC planes and other RC vehicles. This Python code is ...
3
votes
0answers
620 views

Sliding window of entire length of the file

I have a tab delimited file which contains about 2207 rows with 4 columns of floats or int types: ...
2
votes
0answers
71 views

Extract cell values from multiband rasters

I have the following function and code snippet to extract cell values for multiple years, format it, and save to a list. Each raster has 365 bands — one for each day. A separate operation is performed ...
2
votes
0answers
104 views

Fully Constrained Least Squares (FCLS) Linear Spectral Mixture Analysis Method

I have written code using Python for Fully Constrained Least Squares (FCLS) Linear Spectral Mixture Analysis, which could be applied for unmixing multispectral image successfully. However, the ...
2
votes
0answers
31 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. ...
2
votes
0answers
661 views

PyQt frame which changes color with child focus

I am working on an application that has various "panels" contained within splitters. I wanted the panel border to change color when one of it's children gained focus. Here is a simple example of the ...
2
votes
0answers
52 views

Using zip to process widgets flagged as enabled

This code returns a list of widgets from spreadsheet ranges that are enabled for processing. The code works but it is poorly implemented, especially in terms of proper use of zip and layout. The code ...
2
votes
0answers
579 views

Recursively scrape links from web pages and check them

I'm new to programming and especially new to object oriented programming. I have built a web scraper using functional programming and am trying to build another using OOP principles. The overall idea ...
2
votes
0answers
328 views

UK Tax Calculator - First Python program

This is my first Python program and while it's not quite finished I would like to know how I could improve in general as a programmer. This project has be a lot of fun but it has felt more like ...
2
votes
0answers
222 views

Convert python's strftime directives to user-friendly format examples

I'm converting python's very un user-friendly strftime date time directives to user-friendly formats so that users of an API will know how to format a date if they send an invalid format. My thinking ...
2
votes
0answers
462 views

Python scapy subnet mapper

This a follow-up question of Python scapy - TCP port scan of subnet I've decided to make an all powerful subnet mapper in Scapy to better understand how tools like ...
2
votes
0answers
654 views

Optimization Resource File for Robot Framework

I'm looking for optimization between these files, and simplification. If something already exists to do what I have a keyword do, I'd like to know about it. Loops.py is located in one of my other ...
2
votes
0answers
320 views

Python2.7 Some xor fun

After doing the Cryptopals challanges, which I found scrolling through codereview, and finally being able to solve set1 challenge 6. I decided to have a little xor fun, and make an automated xor ...
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 ...
2
votes
0answers
70 views

Parse path string

Suppose path string are encoded in this way: 2T3T5: means move 2 steps, turn right, move 3 steps, turn right, and move 5 steps 32T: which better read as 3(2T), and it means do the following operation ...
2
votes
0answers
117 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 (...
2
votes
0answers
149 views

First basic API using Flask with authentication

I've created my first basic API using Flask, that has the ability to create new tasks, delete tasks, update tasks, handles error pages, and has authentication required. What I would like to know is ...
2
votes
0answers
390 views

Second degree connection ranking

Problem Find 2nd degree connections ( friends’ friends), output these 2nd degree connections ranked by number of common friends (i.e 1st degree connections) with you, (example: if 2nd degree ...
2
votes
0answers
412 views

Tarjan's strongly connected component finding algorithm

Here is my code for Tarjan's strongly connected component algorithm. Please point out any bugs, performance/space (algorithm time/space complexity) optimization or code style issues. ...
2
votes
0answers
469 views

Vertical sum in a given binary tree

I'm working on this problem, Problem statement, Given a Binary Tree, find vertical sum of the nodes that are in same vertical line. Print all sums through different vertical lines. Examples: ...
2
votes
0answers
657 views

Counting numbers in an array that are divisible by any 2 numbers

While solving one question I got stuck with a time limit error. The main objective in question is to count numbers in an array \$A\$ that are either divisible by \$P\$, \$Q\$ or both. Input format: ...
2
votes
0answers
981 views

Find k nearest points

I'm working on a problem to select k nearest points for a given point. Any advice for bugs, improvements are appreciated, including general advice to implement find nearest k points. My major idea is ...
2
votes
0answers
453 views

format any mail into readable text

Scope is to throw any mail, html or plain or multipart into this and receive a readable formatted text that deals with special characters and html issues. Field of usage: System that imports mails ...
2
votes
1answer
118 views

A bitwise common prefix algorithm in Python

Is my algorithm slow because it has problems? Or, is any bitwise common prefix solution not going to give me the performance I'm looking for? After profiling my algorithm, I found that over 60% of ...
2
votes
0answers
58 views

Memcached load generation

This is working but right now it is not giving me the throughput that I want. The main function has the load generation loop (where it is putting work in Queue). I ...
2
votes
0answers
85 views

Identifying Polylines and operating on field values

I'm using Python 2.7.5 in a GIS environment (namely: QGIS 2.8.1, or PyQGIS). sys.version_info(major=2, minor=7, micro=5, releaselevel='final', serial=0) The aim is to identify spatially identical ...
2
votes
0answers
1k views

Optimize QuadTree to find K Nearest Neighbors

I'm looking a way to make my k nearest neighbors search more efficient. The context of the question is that I'm given a list of topics that have a unique ID (integer) and a (x,y) coordinate (floats) ...
2
votes
0answers
169 views

Function that transforms input file based on a numpy poly1d function

I have written a function that gets a function as input (acquired from numpy.poly1d). The function has access to the GUI variables ...
2
votes
0answers
2k views

Encrypt texts, with saved password using pycrypto

I have the code bellow, which is supposed to be used inside a larger program. Please see notes about the requirements below the code. ...
2
votes
0answers
58 views

Microcast algorithm

Following is the main file in the project (executing tasks). It uses the mpi4py module, and multiple processes execute the same code. Please review the code and ...
1
vote
0answers
59 views

AWS plugin to create a CloudFormation stack if it doesn't exist

The following Python class is what I am trying to refactor in the case where I have to add validation of the existence of an AWS cloudformation stack before creating it in the method create_cfn_stack :...