Questions tagged [python-3.x]

Python 3 is the latest version of the Python programming language and was formally released on December 3rd, 2008. Use this tag along with the main python tag to denote programs that are meant to be run on a Python 3 interpreter only. Do not mix this tag with the python-2.x tag.

548 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
3
votes
0answers
302 views

ECDH implementation in python (part 3)

After the first and second part, the primary feedback I got was to rename a lot of my variables as I used the same name for different local variables which is really confusing. I tried to hotfix that, ...
3
votes
0answers
108 views

Cryptocurrency forecasting app

I wrote a cryptocurrency (or any other) market forecasting application in Python 3.5. The code is getting bigger and more complex so I would love if some experts would take a look at it and check and ...
3
votes
0answers
733 views

Implementing a JSON-serializable ORM model

I implemented a library which, amongst other things, implements a JSON-serializable ORM model based on the peewee framework. Here's the relevant excerpt: ...
3
votes
0answers
34 views

aiohttp resources container

I want to simplify aiohttp routes/resources configuration (see this paragraphs). For this task I have written this _resources.py ...
3
votes
0answers
523 views

Hint generation code for freecell game

I am writing a text-based freecell game in python 3. I am looking for a way to generate hints. A hint should simply be all the possible moves that you can make, excluding moving a card to a free cell (...
3
votes
0answers
851 views

Memory optimization when finding the Cartesian product in Python

My function gets the Cartesian product of a list of lists of tuples. The function is correctly producing the list of lists, but it's a memory hog (and leads to a MemoryError for large data sets, with ...
3
votes
0answers
154 views

Simple finite difference employing Maccormack technique

I am relatively new to programming and while I am fairly comfortable with the math, I cannot say with confidence that I feel the same way with programming. Anyway here is a simple finite difference ...
3
votes
0answers
55 views

Automating renaming .pdfs and assisting with uploading files

I'm a notetaker for my college, and as part of my duties I have to upload my notes daily. As I type them, this is something I can do from my computer, without needing a scanner. Generally, this ...
3
votes
0answers
152 views

Finding the maximal bottleneck in a 2D matrix from source to destination

I recently started solving programming challenges and this one is causing me performance trouble. The problem statement is the following: You are given a 2d matrix where each cell contains an ...
3
votes
0answers
2k views

Validating HMAC-SHA256 signature in Python

I am trying to implement HMAC-SHA256 authentication into my Python RESTful API project. I am using Python Eve (built on top of Flask), started with an simplified HMAC-SHA1 example. My application is ...
3
votes
0answers
1k views

Python TicTacToe AlphaBeta Program

I am looking for a review of my perfect TicTacToe algorithm. It will be split up into 3 parts: The function The GameState Class The game (NOT well designed) I am mainly looking for tips and comments ...
3
votes
0answers
88 views

Print Python docstrings when module is executed interactively

I have written a module, which should only be used by means of import, then call the functions as required. I do not want this module to do anything when ran interactively, other than printing out ...
3
votes
0answers
50 views

Python simulacrum of windows copy window

I wrote a program to copy files with an progress bar that looks similar to Windows built in function. The copy function is run in a separate thread and the tkinter GUI is run in the main thread. This ...
3
votes
0answers
51 views

VIM colors downloader in Python, using multiprocessing

I recently posted this script: VIM colors downloader in Python But since I'm not allowed to update the code there, I wanted to get an idea on this version, that uses multiprocessing: ...
3
votes
0answers
148 views

Deque class using typing module

I wanted to make a class for type hinting that the result of a function is a homogenous deque. ...
3
votes
0answers
61 views

How to properly set a different formatter for a specific logger's child?

For certain modules or functions, I want to have a different format for the logged messages. I have done this in a way that looks a bit hacky: I have set a special Logger, containing a special Handler,...
3
votes
0answers
2k views

Breadth-first search: traditional and bidirectional in Python - follow-up

I have refactored the version of the previous (and initial) iteration according to the answer by alexwlchan. As a reminder, this snippet compares breadth-first search against its bidirectional variant....
3
votes
0answers
143 views

Compute the box covering on a graph using CPython

Edit: My initial idea was to use numpy to solve efficiently this problem but after trying without results, someone comment on stackoverflow: "Numpy can speed things up a lot IF your problem is ...
2
votes
1answer
21 views

API design of library for argument inspection & filtering

I wrote the following Python library for getting a callable's argument names, testing whether a callable takes an argument with a given name, and filtering a dict ...
2
votes
0answers
53 views

Start and kill thread on given pid

I have been working on I/O Bound application where I want to learn how I can kill a thread on given PID, by PID I mean a specific URL I want to kill as I later on will do an API or listen to a stream ...
2
votes
1answer
21 views

Using Numba works slower than not using it for my Python code

I thought this community is better place to ask my question so I ask here rather than at StackOverflow. Recently, I learned that Numba can make Python function ...
2
votes
1answer
85 views

Python factory class with dynamic imports

I'm trying to write a factory class that essentially provides a user-friendly frontend to creating objects of different kinds depending on keywords. So the user will just have to import this module, ...
2
votes
1answer
51 views

Create a divisors list and identify primary numbers

I tackled a beginners' exercise: "asks the user for a number and then prints out a list of all the divisors of that number." The workflow I established is: input an integer number, say ...
2
votes
0answers
31 views

Web Scraping data from website using Selenium in python

ApplicationDetail.txt: URL: https://www.abc.com applicationNo : 123456 Application Class: ...
2
votes
0answers
253 views

Discord Bot Python. Selenium screenshots

I wrote my own Discord Bot which is taking screenshot of a specific website. This scrip is very simple and thought it should work fast, but it isn't. I read a lot, and I think I'm not able to improve ...
2
votes
0answers
31 views

Python - preprocessing dataframes data in a class

Context I am building an algorithm that automatically assigns a planning to drivers. However there is a lot of pre-processing and reused outputs. I try to structure it in a maintainable way. Questions ...
2
votes
0answers
53 views

Improved isinstance for IPython

Problem: IPython's autoreload and superreload may reload modules such that obj=Obj() -> ...
2
votes
0answers
32 views

Model View Controller in Python

I have attempted to do Model View Controller in Python for learning. First, I am not sure if dictionaries are faster than lists for about N = 30 (20 to 40) items. Second, how maintainable is this ...
2
votes
0answers
63 views

Gradient descent algorithm for solving localization problem in 3-dimensional space

Task This code accomplishes the Time Difference of Arrival (TDoA) multilateration problem (see) using gradient descent (known otherwise as steepest descent). Goal I'm looking to: a) Improve speed: In ...
2
votes
0answers
29 views

Cave explorer: using stack

Story Original Link written in korean Frodo, a backcountry explorer, came to explore an underground cave with n rooms during his expedition. All rooms are numbered 0 through n-1. There are many, the ...
2
votes
0answers
516 views

Simple multithreading programing in Python to download file from AWS S3

I have written this multithreaded program to download files from AWS S3. Kindly review if it is a correct approach. Code works and downloads the files. But I see an issue occurring sometime (below is ...
2
votes
0answers
25 views

Data Visualization (rendering env)

How can I improve this code? It renders a ML env with openAI gym and matplotlib. I am new to coding so not sure if my variables or format or any lines can be improved. ...
2
votes
0answers
60 views

Cosine Similarity Matrix Loss Function

I am currently implementing this paper on generalised end to end loss: https://arxiv.org/pdf/1710.10467.pdf A batch of N speakers and M utterances are fed to the model which outputs an embedding ...
2
votes
0answers
53 views

How can I shorten the runtime of my simulation?

Before you read the code below, note the following explanation: I have three classes: Driver, Vehicle, and ...
2
votes
0answers
158 views

Providing different __table_args__ to SQLAlchemy mapped class depending on backend DBMS

I need to set different __table_args__ for the mapped class depending on the backend DBMS, e.g. mssql and ...
2
votes
0answers
49 views

Ubuntu GTK+ 3 desktop app, made with Python library PyGObject

I just created my first GTK+ 3 app with Python using PyGObject. It is very nice to be able to make GTK applications using Python, as I love that language. I'm not completely sure if the way I designed ...
2
votes
0answers
32 views

Make a class hierarchy data classes using a meta class

I am redesigning a library, which at the moment uses a lot of boilerplate code in a double hierarchy of classes / metaclasses, to attempt to make it much cleaner and reuse as much as possible what ...
2
votes
0answers
25 views

A task to store user's favorited projects in postgres using python

I am not happy with two functions calling get_user() since while testing I mock get_user and to test with get_user_returns_null case, it returns Null for both ...
2
votes
0answers
171 views

Simple Flask REST API to a MongoDB

I'm writing a simple REST API to my MongoDB using PyMongo (Python 3.7). Each collection I have in the DB has a route (e.g http://the.api.url/collection_name ), and every document under that collection ...
2
votes
0answers
32 views

Maybe with a structural pattern matching interface

With a reference implementation for PEP 622 now available in a Jupyter playground, I decided to copy over my favourite feature of Rust in full to Python. Note: this won't be released until Python 3.10 ...
2
votes
0answers
928 views

Better performance in solution for the Dole Out Cadbury challenge

Dole Out Cadbury Problem Description You are a teacher in reputed school. During Celebration Day you were assigned a task to distribute Cadbury such that maximum children get the chocolate. You have ...
2
votes
0answers
40 views

Genetic sequence analyzer that reads FASTA and GenBank file formats and outputs all possible gene products

I have updated my my gene sequencing program from my previous post. That post explains what each functions accomplish. If you need clarifications feel free to ask. Any tips to make the code more ...
2
votes
0answers
129 views

Performance challenge: Box operations (HackerRank) (C, Python)

Recently I've been doing some challenges on HackerRank and came across this one. First, I tried with Python, and then C. Both of my codes failed due to timeout restrictions. It would be very helpful, ...
2
votes
0answers
34 views

How can the following pandas script be made more efficient?

I have an excel sheet G0.xlsx which has 3 sheets in it Winter, Summer, ...
2
votes
0answers
43 views

Finding, substituting and executing values in dictionaries

I wrote this code for finding, substituting and executing values in dictionary, much like $() bash operator works. I used nested functions for this, forming ...
2
votes
0answers
29 views

Uploading to DB from Excel with Pandas

I have this python script that uses pandas read an excel sheet then to update a sqlite db it works perfectly just wondering if I can speed it up as I am at about 70k lines ...
2
votes
0answers
74 views

Max Heap Implementation in Python

I decided to challenge myself to code this data structure by just seeing how it looks visually and this is what I got. I can change this easily to minheap by changing some greater than (>) operators. ...
2
votes
0answers
31 views

Handling failures in DB transactions

This code is meant to retry the db operation when a DB connection breaks: OperationalError. A transaction can fail for example when a db is being restarted and a commit fails. Or when a network error ...
2
votes
0answers
210 views

Generating markdown documentation for VBA code

Generating documentation for VBA code The goal of this exercise to is create an application which can read module files created in VBA project and generate markdown documentation for them. Key ...
2
votes
0answers
28 views

Gathering data using sqlalchemy from database and making it available using simplified namedtuple object in an iterable class

I wrote the below code today: ...

1
3 4
5
6 7
11