Questions tagged [python]

Python is an interpreted, general-purpose high-level programming language whose design philosophy emphasizes code readability. Use the python tag for all Python related questions. If you believe your question may be even more specific, you can include a version specific tag such as python-3.x.

1,640 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
14 votes
0 answers
789 views

Let's register that Django user

Short intro So, I've been using Django for a while now and thought it would be nice to start a simple application. In an ideal World, each app must have a way of letting its users register and that's ...
14 votes
0 answers
928 views

Django on virtual machine - watching changes in static files and autocompiling LESS without inotify

I'm setting up a Django development environment using Vagrant to run an Ubuntu virtual machine on VirtualBox. As this is a student project run mostly by very amateur coders and I want everyone to be ...
  • 378
13 votes
0 answers
1k views

Flask view dependency injection

I've been into trying to have an as simple as possible dependency container in Python and with your help managed to conceive TinyDIC, many thanks. Now, I use Flask for my apps, and from by background ...
's user avatar
11 votes
0 answers
3k views

Sending notifications with Django channels

I have project on Django wich use Django Channels. I use Django Channel for sending notifications to users who are subscribed to articles changes (adding/editing/deleting comments on article). So I'...
  • 211
9 votes
0 answers
1k views

Cyther: The Cross Platform Cython/Python Compiler (Take 2)

I recently posted an earlier version of this code on Code Review, and now with the given suggestions and many other improvements, I am back. I included the description of exactly what Cyther is ...
8 votes
0 answers
74 views

A program that calculates how dense each character appears when printed

I wanted to know how "dark" each character is when printed. I thought that this may be useful when doing ASCII-art to help with shading. I decided to write a program to objectively measure ...
8 votes
0 answers
133 views

Calculation of independence test statistic

This code (~30lines) detects independence between variables in a dataset, by using a bootstrap of a statistic. This is fully-broadcasted, but it's still long. Reading it, or making it run, do you ...
  • 195
8 votes
0 answers
2k views

Joystick to mouse/keyboard mapping program

I've been working on a project to map a joystick (in my case Logitech Extreme 3D) to mouse and keyboard so I can use it for web games that don't support gamesticks. My design goals are: Flexibility - ...
  • 1,690
7 votes
0 answers
142 views

Making this python chess engine faster

I've implemented a chess engine using the python chess move generation library (which I assumed to be reasonably fast), and have implemented various optimisation techniques for search and move ...
  • 81
7 votes
0 answers
99 views

Using get_dummies to create a Simple Recommender System - Cold Start

Question: was using get_dummies a good choice for converting categorical strings? I used get_dummies to convert categorical ...
7 votes
0 answers
158 views

Multithreaded HD Image Processing + Logistic reg. Classifier + Visualization

[I'm awaiting suggestions for improvement/optimization/more speed/general feedback ...] This code takes a label and a folder path of subfolders as input that have certain labels ex: trees, cats with ...
7 votes
0 answers
1k views

Codewars: N-dimensional Von Neumann Neighborhood in a matrix

Task: For creating this challenge on Codewars I need a very performant function that calculates Von Neumann Neighborhood in a N-dimensional array. This function will be called about 2000 times The ...
  • 439
7 votes
0 answers
985 views

Parsing different categories using Scrapy from a webpage

I've written a script in Python Scrapy to parse different "model", "country" and "year" of various bikes from a webpage. There are several subcategories to track to reach ...
  • 2,459
7 votes
0 answers
1k views

Read quantization tables from JPEG files

I'm developing an application that will hide information inside the quantization tables of JPEG files. It's called DQTsteg, if you want to know more about what I'm attempting to do. Right now I'm ...
  • 293
7 votes
0 answers
477 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 ...
7 votes
0 answers
2k views

Improving the Flask cache decorator

In my rumblings developing flask applications I found the caching decorator. The decorator is a short and well-written piece of code, but I feel like it misses the few points bellow: It only caches ...
's user avatar
7 votes
1 answer
131 views

Structuring of my tkinter music player program

This music player app hasn't really completed yet but it runs the basic functions of a music player, which include play/pause, volume adjustment, next/prev, shuffle and repeat functionalities. However,...
6 votes
0 answers
121 views

Python asyncio multithread wrapper

For my application, I needed a lightweight way to launch multiple tasks and monitor their completion in a main loop periodically or use callbacks. The main loop is going to be busy most of the time ...
6 votes
1 answer
193 views

Sinewaves and FFT plotter

I am trying to code a sin wave with 5 sliders: frequency, amplitude, phase change, number of data points, and time. I am currently trying to link my phase change slider with my graph so that it ...
  • 91
6 votes
0 answers
115 views

Booking an East London Tennis Court

Description I'm not sure if it Covid-19 but lately it is impossible to book a tennis court in my area on time. It's always full or maybe just don't check enough :) To beat the queue and get notified ...
  • 11.4k
6 votes
1 answer
207 views

Image puzzle PIL tkinter

I'm a hobbyist programmer(just having fun) created a small script that takes a photo and resizes it, then cuts it up into 24 pieces. The chunks are transposed and made into buttons. Your task is to ...
  • 186
6 votes
0 answers
287 views

Xero API Client in Django

I'm not actually that new to writing Python. But I've no formal training and have only learnt to build applications to solve problems for my job out of necessity. Starting to bring my existing skills ...
  • 61
6 votes
0 answers
101 views

Code optimisation: Converting dataframe to numpy's ndarray

I am working with a dataframe of over 21M rows. ...
  • 161
6 votes
0 answers
72 views

Subtracting elements of datasets of an HDF5 file

I am trying to solve the following problem: Input: Input is two arrays (Nx4, sorted in column-2) stored in datasets-1 and 2 in HDF5 file (input.h5). N is huge (...
  • 61
6 votes
0 answers
95 views

K nearest neighbours algorithm

Here is a project that I worked on for a few days in June 2020. Since the algorithm is extremely slow, I looked into methods in order to parallelize operations but did not obtain any satisfactory ...
6 votes
0 answers
82 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. ...
  • 69
6 votes
0 answers
248 views

How to make my groupby and transpose operations efficient?

I have a DataFrame of size 3,745,802 rows and 30 columns. I would like to perform certain groupby and ...
  • 235
6 votes
0 answers
4k views

Cubic spline interpolation in Python from scratch

I implemented the cubic spline interpolation explained in https://en.wikipedia.org/wiki/Spline_interpolation as a Python class. Of course, such an interpolation should exist already in some Python ...
6 votes
0 answers
220 views

Reading sparse matrix from binary file

I have binary files containing sparse matrices. Their format is: number of rows int length of a row int column index int value float Reading ...
  • 161
6 votes
0 answers
948 views

2048 AI in Python 3

I am working on an 2048 AI and this is my code so far. In the game 2048 you have a 4x4 grid in that some random so named tiles spawn. Each tile has a number. The lowest number is 2. By using the left,...
6 votes
0 answers
782 views

Asyncio HTTP Request Queue

I wrote a simple sitemap.xml checker using asyncio and aiohttp. I followed the documentation demonstrating the producer/consumer pattern. However, I noticed that as the URLs scale larger, it seems to ...
's user avatar
6 votes
0 answers
666 views

Laminar flow in a pipe animation using Tkinter

I wrote this simple particle flow animation with Tkinter. I wanted to ask if there is some major improvements you can think of regarding the animation motor or the documentation of my code? I noticed ...
6 votes
0 answers
2k views

Fibonacci heap in Python

I have this implementation of the Fibonacci heap in Python: ...
  • 26.1k
6 votes
0 answers
237 views

Selection sort with reduced comparison count: Python iteration 2

Follow up to Selection sort with reduced comparison count - semi-final Iteration? My goal (and excuse not to tag reinventing…) is to have presentable code to argue the viability of reducing the number ...
  • 4,958
6 votes
0 answers
8k views

Example of multithreading in Python3 / PyQt5 using QThread

I wanted to make a simple example of multithreading with QThread in PyQt5 / Python3. The script generates a set of QLineEdits and buttons to start and stop a set of ...
  • 161
6 votes
0 answers
408 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
6 votes
0 answers
2k views

Calculating T-Test within Large Pandas Dataframes

The below code runs a t-statistic within a large dataframe (rnadf) based on masked values from another dataframe (cnvdf_maked). ...
6 votes
0 answers
76 views

Pyspark Solver for Tiered Board Games

I've written a Pyspark program that will completely solve a tiered board game (no loops, each game position is a member of only one tier) and writes each tier to a file. It also determines the ...
  • 61
6 votes
0 answers
3k views

Real-time bitcoin data feed and storage using websocket framework

I'm trying to create data feed script for real time bitcoin data for OkCoin exchange using their websocket API (documentation) and a database manager for storing. There are two channels I am ...
5 votes
0 answers
44 views

Message-free flow-oriented logger

Today, I've got a small FlowLogger for you to review. The idea is not to log pure messages, but focus on the flow of the app that might contain such items as: <...
  • 43.9k
5 votes
0 answers
45 views

Go Chess (weiqi) in Python using Tkinter

The Game Go or weiqi is an amazingly simple yet complex board game. This game is typically played on a 19x19 grid, and pieces are played on the intersections of lines. Pieces are removed when they are ...
  • 349
5 votes
0 answers
60 views

A Python script that creates n-flakes

I have written a simple Python script that generates n-flakes using matplotlib. Wikipedia article on N-flake. I wrote two functions, one function generates pentaflake, the other generates hexaflake, I ...
5 votes
0 answers
64 views

A Python 3 script that generates art using matplotlib

I am always super interested in both science and art, science and art are two different ways to describe the objective reality, they are two sides of the same coin, in many areas they overlap, and ...
5 votes
0 answers
277 views

Python 3 script to make photo collages

I have written a Python script that takes a list of filenames of pictures and generates a photo collage of them. This is my most complex project yet, and I have written it completely by myself (like I ...
5 votes
0 answers
139 views

@lazylist - Converts a Python Generator to a List without evaluating every element

I made a LazyList class that can wrap an iterable (list, generator etc.) and turn it into a MutableSequence (like ...
  • 2,210
5 votes
1 answer
86 views

GUI that reads data and generates/ saves charts

I have a program that uses pandas to read csv files and then generates and saves graphical charts. I have been trying to follow the SOLID principles so I have tried to seperate responsibilities. So ...
5 votes
0 answers
87 views

Thread Art Generation that Creates Embroidery Files

I have made a thread art generator that creates thread patterns from images. Mine is a bit different as it outputs an embroidery file (It embroiders quite nicely, though the settings need a lot of ...
5 votes
0 answers
708 views

Scraping OddsPortal with requests only

This is a scraper written to do most of what had been attempted by another user in this question: How can I optimise this webscraping code I did the rewrite because I felt bad that the new user didn't ...
  • 53.5k
5 votes
0 answers
160 views

Pi Calculator Using BBP (Bailey–Borwein–Plouffe) - Written in Cython With MPFR

I wrote a Pi Calculator using the BBP Algorithm in Cython. My specific goals are make the code more legible and more performant. This is a purely academic script in order to teach me how to implement ...
5 votes
0 answers
133 views

Process Injector using ctypes and the Windows API

To get some practice with the Windows API and ctypes, I decided to write a program capable of injecting and running shellcode inside of another specified process. ...

1
2 3 4 5
33