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.

60 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
6 votes
0 answers
84 views

Python - Displaying messages in ArcPy/IDLE

I have created a wrapper for displaying messages with ArcPy and IDLE (as that is all I have available to myself due to certain circumstances) as I frequently use both to test and develop new tools. ...
user avatar
6 votes
0 answers
426 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 ...
  • 449
5 votes
0 answers
228 views

Speeding up the implementation of Stochastic Gradient Ascent in Python

I am implementing a time-dependent Recommender System which applies BPR (Bayesian Personalized Ranking), where Stochastic Gradient Ascent is used to learn the parameters of the model. Such that, one ...
  • 51
5 votes
0 answers
201 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 ...
4 votes
0 answers
162 views

Simple chat server in Python

I'm new to both Python and socket programming and figured setting up a simple chat server would be good practice. In addition to general critiques of the code, I have specific questions: What are the ...
4 votes
0 answers
49 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. ...
  • 225
4 votes
0 answers
88 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
0 answers
1k 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 ...
  • 495
4 votes
0 answers
865 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 ...
  • 381
3 votes
0 answers
50 views

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 ...
  • 31
3 votes
0 answers
260 views

Store special deals, like 3 for 2

I have to apply two deals on the cart. Buy 3 (equal) items and pay for 2 Buy 3 (in a set of items) and the cheapest is free Items in cart: ...
3 votes
0 answers
249 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 ...
  • 7,244
3 votes
0 answers
62 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 ...
  • 131
3 votes
0 answers
282 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 ...
  • 231
3 votes
0 answers
77 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
0 answers
362 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 ...
  • 11.5k
3 votes
0 answers
108 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,443
3 votes
0 answers
711 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
0 answers
704 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,443
3 votes
0 answers
570 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
0 answers
885 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
0 answers
708 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
0 answers
34 views

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'...
  • 21
2 votes
0 answers
101 views

Find the available squares for rooks in empty board using boolean arrays

I will describe two techniques, then the question will be how I can make an algorithm that is more efficient, if possible. I want to find an efficient way to determine the squares where the pieces on ...
  • 143
2 votes
0 answers
107 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 ...
  • 121
2 votes
0 answers
299 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
0 answers
33 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. ...
  • 275
2 votes
0 answers
1k 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 ...
  • 261
2 votes
0 answers
60 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 ...
  • 179
2 votes
0 answers
953 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 ...
  • 121
2 votes
0 answers
913 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
0 answers
243 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
0 answers
727 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 ...
  • 11.5k
2 votes
0 answers
871 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
0 answers
44 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 ...
  • 133
2 votes
0 answers
142 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 ...
  • 3,443
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 (...
2 votes
0 answers
161 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 ...
  • 103
2 votes
0 answers
538 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 ...
  • 3,443
2 votes
0 answers
462 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. ...
  • 3,443
2 votes
0 answers
593 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: ...
  • 3,443
2 votes
0 answers
715 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: ...
  • 245
2 votes
0 answers
1k 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 ...
  • 3,443
2 votes
0 answers
534 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
0 answers
67 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 ...
  • 213
2 votes
0 answers
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) ...
  • 113
2 votes
0 answers
176 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
0 answers
60 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
0 answers
100 views

Script to check a web service

I'm a Python novice. The system I'm using is called IBM Maximo Asset Management. In Maximo, we can write Python scripts that utilize Maximo's Java API/methods. So the script is technically a Jython ...
  • 198
1 vote
0 answers
57 views

Reading attachment data from a PostgreSQL table with python

I have developed this script to find the counts of attachment records stored in a table in PostgreSQL for different other tables. I check if the res_id field of <...