Episode #125 of the Stack Overflow podcast is here. We talk Tilde Club and mechanical keyboards. Listen now

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.

Filter by
Sorted by
Tagged with
4
votes
1answer
113 views

Ultra fast Amazon scraper multi-threaded

This is a follow up to the code here: Web scraper that extracts urls from Amazon and eBay A multi-threaded modification to the previous version that is Amazon focused and most of the necessary ...
6
votes
0answers
76 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 ...
6
votes
1answer
48 views

Menu with buttons using pygame

I wrote this to teach myself how to make a menu with buttons and I want to know if I've done well and if there's any way to make it shorter and/or more efficient. ...
3
votes
1answer
38 views

A runtime benchmark for multiple programs using the Python subprocess module

I would like feedback on my benchmark script. What's another method for benchmarking that might be better/easier? Overhead I've found that subprocess.run has an ...
8
votes
3answers
2k views

AniPop - The anime downloader

Note: The topics of performance and Selenium/BS4 has not been addressed yet, so this question can still receive a better answer! This is a recreational script made to update my home server w/ the ...
-1
votes
0answers
42 views

Django Python increment database value using model save function [on hold]

I'm looking for a more efficient way to increment the already saved value in the database by the value returned to the model from a form submit. ...
3
votes
1answer
35 views

Simple projects planner on PyQt5

My task was : Create a Python application to display the active status of your IT project. Everyone the project has its own unique number that is generated at the stage of receipt project into the ...
3
votes
2answers
93 views

Fetching counties and localities using JSON API calls

I'm using the below code to call different methods from an API: ...
-2
votes
0answers
24 views

Collision Detection Code doesn't detect all the collision [on hold]

I am doing capsule-capsule collision detection. It's not perfect; it lets through some collisions. I'm thinking it may have to do with floating point error, but I don't know how to correct for that. I ...
2
votes
0answers
24 views

OOP parsing for DB dump XML Python

I am parsing large XML (DB dump). So, the content looks like many different objects with their properties and dependencies (foreign keys). My way to do it - using lxml.etree (iterparse): ...
4
votes
1answer
79 views

Min Heap Tree Implementation in python 3

I wrote a min-heap using a binary tree. How can I improve the time complexity of insert and delete function to be \$\mathcal{O}(log(n))\$? ...
2
votes
0answers
23 views

Python image combiner reading writing

I am writing a simple script that will combine two images at a pixel level, selecting every other pixel from one image, and the other pixels from a second image. ...
3
votes
1answer
33 views

A class and a function to create and light up buttons in PyGame

This is my first ever try at making reusable code. The function makes use of two images to give the illusion of turning on and turning off a button in pygame. I would like to know what would you do ...
-2
votes
0answers
24 views

How Do You Create a 2D Numpy Array out of a string [closed]

On project Euler 67 they give you this triangle ...
4
votes
3answers
392 views

Program to print the multiple occurrence of numbers in a list

I wrote this program to print how many times each number occurs in a list: ...
6
votes
1answer
131 views

Web scraper that extracts urls from Amazon and eBay

Description: This is a simple script for scraping Amazon and eBay category, sub-category and product URLs and saving contents to files. In case of previously saved files, the files will be read and no ...
4
votes
0answers
118 views

The anime downloader [duplicate]

NOTE: Here's the latest version of this program, since this question idled out. This is a recreational script made to update my home server w/ the latest anime from HorribleSubs. I'd like to know if ...
12
votes
3answers
745 views

Python algorithm that converts array-like data into MathJax

I frequently use MathJax, and often I need to write matrices. Since writing matrices using MathJax is very tiresome task, I decided to automate it. Code: ...
1
vote
1answer
27 views

Updating NamedTuple members based on a function and previous value

I'm using a NamedTuple to represent the state of my game while it's running. The user can alter these settings using key presses, so in my PyGame key handler, I'm ...
1
vote
2answers
79 views

Breadth-first search(BFS) Implementation in Python 3 [closed]

I have implemented a BFS. Does this look like a proper implementation of BFS in Python 3? And if you think something needs to be improved, say it. ...
5
votes
1answer
37 views

“Bigint” decimal to two's complement binary list of bytes in Python

I'm toying with the idea of writing a "bigint" library in 6502 assembler that would handle variable-length integers up to 255 bytes long. Since this would be unit tested using pytest, and to help wrap ...
8
votes
4answers
4k views

Find the closest enemy

I'm currently creating a 2d game in python. I have to calculate the closest enemy so the player knows which one to target. I have the following function to accomplish this task: ...
5
votes
1answer
38 views

Simplified Blackjack in Python

I just started learning python a couple of weeks back from and like many others here, I too seek feedback on my simplified Blackjack game. I would like to know if the code could have been more elegant/...
9
votes
2answers
1k views

Linux Commands in Python

I've decided to write some Linux commands in Python. Below is a list, along with some constraints (if you're unfamiliar with Linux, the top of the program along has a description about each command ...
4
votes
1answer
62 views

a function to partition images into patches

I wrote a function that partitions an image into multiple patches. Here is the function, are there any suggestions to make it better or more production ready in terms of the best software practice? <...
1
vote
1answer
81 views

Ternary search tree implementation in python 3

I have implemented a Ternary search tree. It works well. But if you think something needs to be improved, say it. This code was tested in Python 3.7.4. ...
5
votes
3answers
458 views

Largest number order in string

Given a string, assuming the string is numbers only, rearrange the string to that it is the greatest possible number. Below is my solution to the problem above. I'd like feedback mainly on the ...
5
votes
2answers
877 views

Sum of all digits in a string

Given a string, return the sum of all the numbers in the string, 0 if none are present. Below is my solution for the problem above. I feel like this can be turned into one line. I would really only ...
5
votes
1answer
50 views

GMAIL API -Create/Send/Search messages for keyword

I have written below code using GMAIL API reference which creates a basic message, sends it and also lists all the messages from user's mailbox matching a keyword.It works fine. Looking for experts ...
11
votes
3answers
652 views

Generating sequential alphanumeric values that match a certain pattern

I'm working on generating large volumes of test data for some performance testing. Part of this is going to involve generating a lot of values that represent an "MBI", which is a certain kind of alpha-...
4
votes
1answer
58 views

Singly linked list implementation in python 3

I have implemented a Singly linked list. It works well. But if you think something needs to be improved, say it. This code was tested in Python 3.7.4. ...
3
votes
0answers
89 views

Calculating the total sum of inversion count for all subarrays

My approach was to visit all inversion count pair and count how many subarrays these pair contribute. Visiting every pair requires \$\mathcal{O}(n^2)\$ time, but I want an optimized version of this, ...
5
votes
1answer
42 views

Calculating silence in a WAV file

I made this script to calculate the amount of silence in seconds in an audio file. Is this a good method to do this, and if yes, can it be improved? It takes about 4 seconds for 20 audio files of 100-...
1
vote
1answer
67 views

HashTable implementation in Python 3

I have implemented a hash table. It works well. But if you think something needs to be improved, say it. This code was tested in Python 3.7.4. ...
6
votes
2answers
223 views

Tokenizing SGML text for NLTK analysis

I have an NLTK parsing function that I am using to parse a ~2GB text file of a TREC dataset. The goal for this dataset is tokenize the entire collection, perform some calculations (such as calculating ...
0
votes
0answers
29 views

buying stock module - nonlocal vs global variable or others? [duplicate]

[Background explain] I wrote three Flask views and module interact with the views. I do this one module called /buy using different scenario cases based on flag. Zero view if user come in GET, ...
2
votes
0answers
57 views

WARNING - Codewars Kata - spoiler - getting to next level pythonic

The challenge: You managed to send your friend to queue for tickets in your stead, but there is a catch: he will get there only if you tell him how much that is going to take. And everybody can ...
9
votes
1answer
87 views

Predator-prey simulation

I made a random-walk predator-prey simulation that focuses on individual animals instead of the (maybe) more common array-based approach. I'd like to hear your opinion about this: how could the ...
6
votes
1answer
57 views

Flask application for buying stocks

I wrote three Flask views below. First view input stock code Second view get the stock details (name, price) of the stock by using 3rd party api get the balance cash of DB and show to the view ...
5
votes
1answer
62 views

Timeout Error in Fraudulent Activity Notification HackerRank

I am solving this problem: Fraudulent Activity Notifications on HackerRank. I am done with my code and is working, but it is inefficient as well for very large inputs. I don't know but after all ...
7
votes
2answers
883 views

Displaying characteristics of the Hero in a console game

I am beginner in OOP. And i want you to analyze my piece of code and give me some recommendations. My task was : RPG game give a chance to choose race of Hero : Argonian, Breton, altmer, nord. In ...
5
votes
2answers
89 views

Fantasy Game Inventory - Automate the Boring Stuff with Python

Below is my code for the Fantasy Game Inventory problem from Chapter 5 of Automate the Boring Stuff with Python. Is there anything I can do to make it cleaner or more efficient? The code starts out ...
11
votes
2answers
126 views

Segmented wheel Sieve of Eratosthenes in Python

Here is a new version of a segmented and wheel factorized Sieve of Eratosthenes. It currently uses mod 30 wheel factorization to eliminate multiples of 2, 3, and 5 in the sieve data structure to gain ...
8
votes
2answers
125 views

My third game - Poker hand strength analyzer

I'm writting this poker hand evaluator and it's really coming along. But, as you can see I repeat myself many times and I would love to know what's your thought process when you're repeating yourself? ...
3
votes
1answer
39 views

Quick Sort implementation in python

Implemented the quick sort algorithm in python, It was just for learning it, now I want to port it to C. Thoughts on the quality of my python implementation? ...
2
votes
1answer
47 views

Given an array, find all its elements that can become a leader, after increasing by 1 all of the numbers in some segment of a given length

I was successful in solving a challenge in codility, but my solution failed performance tests. How can I improve my solution? Challenge: Integers K, M and a non-empty array A consisting of N ...
-1
votes
3answers
116 views

Heap sort implementation in Python 3

This code relies on Python3.7.4 I'm learning Heapsort in python 3. Please show me the errors in my code. Runs on my computer but tell me if Python rules or not. ...
0
votes
1answer
66 views

Aggregating recent trading data from Bitcoin derivatives exchange

As a component of some trading software, I wrote function parse_ticks(), as part of an Exchange class that models the Bitcoin ...
3
votes
1answer
42 views

File Encryption

I'n written this small file encryption module to work on my skills with the os module. It's my very first time using it to navigate files and file structures, so I'...
1
vote
2answers
76 views

Unit tests for anagram finder

I did this test for a job and the feedback was: "while many were added to test private methods, they did not do anything to ensure the public interface worked correctly, edge cases were missed" But ...