Python is an interpreted, general-purpose high-level programming language whose design philosophy emphasizes code readability.

learn more… | top users | synonyms

2
votes
0answers
15 views

Make one greenlet tell another to shutdown

I am building a commandline app to check proxies, which has a daemon flag (running forever or just once). There are producers, checkers and storers. I want them to run in parallel and be able to ...
1
vote
0answers
11 views

Simple PyQt5 counting GUI

I just began learning how to use signals and slots in PyQt5, and so I made a cute (pun intended) little program to display just one button. When the button is pressed a thread is spawned which will ...
2
votes
1answer
60 views

My attempt at Dijkstra's Algorithm in Python 3

I am practicing my coding at HackerRank. The exact problem statement can be found here, but to summarize, it is finding the distances of the shortest path from a starting node to every other node in a ...
1
vote
1answer
34 views

Project Euler 12 (triangle numbers), solved using functools.reduce() and looping

I have solved problem 12 on Project Euler website, which reads: The sequence of triangle numbers is generated by adding the natural numbers. So the 7th triangle number would be 1 + 2 + 3 + 4 + 5 ...
3
votes
1answer
37 views

Naughts and Crosses: Human vs Computer in Python

So I am very new to programming and I am trying to pick up Python as a first language. I have programmed a simple game of naughts and crosses, but it is very wordy and there must be a simpler/quicker ...
5
votes
2answers
1k views

Which is better code for implementing quicksort?

This is how I used to implement quicksort: ...
2
votes
2answers
390 views

A simple daily horoscope

I wrote a simple daily horoscope in Python using Beautiful Soup as scraper. It works fine but the code can use some sort of a... direction if you want to put it that way. I have used underscores in my ...
-3
votes
0answers
17 views

Invalid syntax error [on hold]

l'm a fresh python user and l'm trying to create a calculator. l run into a problem "invalid syntax" but l could not find a solution. The error is related to Stroke function. In Stroke function, ...
3
votes
1answer
37 views

Search in sorted matrix NxM

The problem (from Cracking the Coding book): Given an NxM matrix in which each row and each column is sorted in ascending order, write a method to find an element. I thought of a modified ...
3
votes
2answers
29 views

Python wrapper class around HTTP API

I wrote this little class to wrap around a work-in-progress, poorly documented API and I'd like to know what else can be improved. I feel like there's a lot of repetition in the functions and I'd love ...
-1
votes
1answer
28 views

Selenium Kijiji web scraper

I have this script working pretty well but I know that there must be many things that I could do better to make it more efficient. ...
5
votes
2answers
77 views
4
votes
1answer
39 views

Conditional removal of columns in sparse matrix

I have a large dataset (78k instances x 490k features) that is loaded as a scipy.sparse.csr_matrix format. From this dataset I want to filter certain features (i.e. ...
-1
votes
0answers
16 views

Send newest file as attachment with gmail [on hold]

I am struggling to find a solution to send by email (with gmail) the latest/newest file located in a directory as an attachment. For the moment I achieved to send e-mail with gmail (see my script ...
3
votes
2answers
79 views

Change-making problem with specific constraints

I am a new Pythoner. I have solved a OJ project with Python. Can you tell me how can I solve it more Pythonically? Problem Description: There are n coin denominations, each with an unlimited ...
2
votes
0answers
42 views

GUI Elements for pygame games

I've been making games using the Pygame module recently. I've noticed that Pygame has no builtin GUI elements. To save time for me (and hopefully other people), I have created some very simple GUI ...
1
vote
1answer
21 views

Django class based view URL API

I kind of started making an API for my site in a Django class based view because it seemed logical and now it has gotten quite large and unruly and I am starting to wonder if I am doing this correctly....
0
votes
0answers
14 views

Weird neural network behavior [on hold]

Disclamer: the code works without errors, but I've done something wrong, so the network does not work as it's supposed to. I'm trying to write a neural network that requires as an input: 1)a list of ...
2
votes
1answer
43 views

Order Statistics Tree on top of Treap

I built an Order Statistics tree on top of a Treap in order to solve this HackerRank problem. It works (passed all test cases). Any comments whatsoever would be greatly appreciated. ...
7
votes
1answer
86 views

Arabic numbers to Roman numerals and back

I have decided to give python a try and have to start out at the very basics, so I chose this well-represented kata. The code aims to convert Arabic numbers between 1 and 3999 to Roman numerals and ...
0
votes
0answers
20 views

Yathzee how to use classes instead of global [on hold]

The .py can be found here: Yathzee.py The game itself is in English and at the moment only the single player works. How can I make classes instead of globals? I learned it this way at my school :/
3
votes
0answers
32 views

Python Politico API attempt

I love politics, and I love programming, so I figured why not try and combine the two for something to do? I'm making a work-in-progress (but runnable at this stage) Politico api that I call "...
3
votes
1answer
65 views

Beginner attempt at a text adventure v2

Based upon feedback received in this post I've amended my game and would very much appreciate further feedback on it's current state(work in progress) and any suggestions on what I could implement in ...
3
votes
2answers
81 views

Model design for Online Food order app

I have been trying to develop online food order application. I have taken the concept of zomato.com where a user or say owner registers his/her restaurant. After adding the restaurant, an executive ...
-2
votes
1answer
53 views

Sorting using heap sort algorithm? [on hold]

I tried to write a heap sort program myself for Leetcode 217. Contains Duplicate as below rather than using Python built-in sort method. Leetcode should accept heap sort method, but for some reasons I ...
5
votes
1answer
83 views

Flight booking system

I'm attempting to improve my OOP design skills through solving sample problems. Below is an implementation of a flight booking system where the passenger can only request a seat class, but no number. ...
3
votes
1answer
56 views

Sorting two lists

This sorts two lists (a, b) according to aand returns two sorted lists separately: ...
3
votes
0answers
25 views

TCP chat room in Python

I have recently started looking into networking with Python. I saw some tutorials about the socket library so I decided to give a "live chat room" idea a go. It works (on Windows, ...
3
votes
3answers
137 views

Binary search of an integer array

I'm a beginner. This is my implementation of binary search algorithm in Python. Please review my code and give your valuable inputs for further improvements on overall coding style, rare cases etc. <...
1
vote
1answer
44 views

Decoupled chain of responsibility in Python

I've started to learn Python today. I'm trying to write decoupled middleware or chain of responsibility pattern. In my app I have some two classes: abstract class or interface named Processable ...
1
vote
1answer
30 views

SQLite database for a micro/tumble blog application

I'm creating a personal website where, among other things, there is a blog, or a "microblog" (I'm still not sure how to define the two), where I will be writing articles and having users, who will ...
0
votes
1answer
28 views

Requesting credentials from users

I need to handle configuration errors and ask the user for the right credentials if something is wrong. I cannot decide between three implementations. Which style is better in Python and why? A: <...
0
votes
0answers
22 views

Boost::python class overloading, issues in exposing more than one constructor

I am very new to boost::python and I am doing the first experiments. The following code works, but how to improve the code exposing also the non empty constructor? Some failed attempts have been ...
3
votes
2answers
137 views

My beginner attempt at a text adventure

I'm a beginner working on a text adventure. It's quite bare-bones at this point but I would appreciate feedback before I continue and the flaws in my code become further ingrained. I plan to add an ...
2
votes
1answer
39 views

Randomly generated world for text-based RPG

I am developing a text-based RPG with a randomly generated world space. I have built a light engine to produce a world for me and fill it with 'world objects' like trees, mountains, villages, and the ...
7
votes
3answers
111 views

Sending users to web pages to download Pokemon episodes

I have a python code named seasons.py which uses inputs to open different web pages in which there are links to download Pokémon episodes. The program has a module called seasons.py where it returns ...
2
votes
2answers
75 views

Count consecutive ones in a binary list

There is a list consisting of zeroes and ones. I want to find out the length of the longest streak of ones. Is there a better solution? ...
6
votes
3answers
409 views

Simple MAC converter

I'm new to Python and experimenting with some simple scripts. I would appreciate if you could give me some suggestions on how the following code can be improved or made simpler or anything in general. ...
10
votes
6answers
2k views
-1
votes
0answers
19 views

Yahtzee using Asciitable, need to assign player points [closed]

I'm currently working on a yahtzee board, but I'm walking into problems I have a hard time figuring out, my code is looking like this currently: ...
4
votes
0answers
43 views
+50

setup.py with data_files and __author__ parsing

All my projects have a fairly similar package layout: ...
2
votes
2answers
57 views

Opening programs from a simple spot

This is a simple program that opens programs from a simple spot: ...
2
votes
1answer
14 views

Instantiating icons, labels, and text fields for a contact form

While teaching myself Wx using this GridSizerTutorial page, I suddenly realized that there was a construct in Python that would let me considerably shorten the initialization code below. The three ...
5
votes
2answers
68 views

Expandable Tic-Tac-Toe Console Game in Python

I've created a console based Tic-Tac-Toe game in python that has the ability to be expanded to a 9x9 playing field or more if you wanted to. By default it's 3x3. Github link: https://github.com/Weffe/...
8
votes
1answer
73 views

Flipbook type animation with Tkinter

I am writing a program in Python that takes a folder of images and animates them. For example, going through a list of pictures like this and animating them one by one: Relevant features include: ...
5
votes
2answers
52 views

Cross-platform file hash sum generator in Python

I'm back for more community punishment review of my own scripts and code! This time, I'm looking for general code review of my approach to a Python way of getting one or more hash sums for a provided ...
3
votes
3answers
76 views

BMI calculator in Python

This is my first attempt at writing a programme: a BMI calculator written in Python. Please give me feedback on the programme overall, as well as how easy the code is to interpret and adapt. ...
6
votes
2answers
81 views

Testing Out Testing

I've been learning about unit testing with pytest recently, trying to figure out what is and isn't a valuable thing to test. I'm very new to it, so I thought a review would be a good way to learn ...
1
vote
1answer
57 views

Print tree level by level including Empty node

Here is my code to print tree in a level by level way. It needs to print an empty node as well to keep tree structure like full binary tree for elegancy reasons. I'm wondering if anything you think ...