Skip to main content
Search type Search syntax
Tags [tag]
Exact "words here"
Author user:1234
user:me (yours)
Score score:3 (3+)
score:0 (none)
Answers answers:3 (3+)
answers:0 (none)
isaccepted:yes
hasaccepted:no
inquestion:1234
Views views:250
Code code:"if (foo != bar)"
Sections title:apples
body:"apples oranges"
URL url:"*.example.com"
Saves in:saves
Status closed:yes
duplicate:no
migrated:no
wiki:no
Types is:question
is:answer
Exclude -[tag]
-apples
For more details on advanced search visit our help page
Results tagged with
Search options not deleted user 171983

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.

6 votes
Accepted

Simple variation on a Trie for prefix search in a large list of words

(I'll admit I'm surprised the trie isn't performing better, but it's basically many nested dictionaries, which imply a lot of overhead in Python.) …
gazoh's user avatar
  • 3,399
1 vote
Accepted

Swapping of element with its neighboring element (Python)

Naming conventions Python has a best practice guide for style and naming conventions called PEP 8. … Swapping elements In Python, you can swap the values of two variables using the following construct: a, b = b, a Your way of using a temporary variable is more language agnostic, but the Python way …
gazoh's user avatar
  • 3,399
2 votes

Noise dosimeter in Python

First, I'd suggest reading PEP 8 – Style Guide for Python Code and PEP 257 – Docstring Conventions and keeping that in mind when writing code. …
gazoh's user avatar
  • 3,399
4 votes
Accepted

Library: Point class

Such a concept doesn't really exist in Python, and top-level functions would be preferred for this kind of functionality. …
gazoh's user avatar
  • 3,399
4 votes

Generate all lines from a file matching a given word list

You can extract the duplicated code in a function. Since your function is a generator, you can delegate the operations to another generator using yield from. Some other remarks: the name object_or_fi …
gazoh's user avatar
  • 3,399
2 votes

Friendly probability puzzle solved with simulation

Your code is mostly well laid-out and clear. The only thing I'd suggest working on is naming, you use too many abbreviations and the duel method should have a verb in its name. However, the logic need …
gazoh's user avatar
  • 3,399
3 votes
Accepted

Validating a Sudoku Board in Python

Naming Your function names has_valid_rows has_valid_columns and has_valid_subgrids are misleading: they imply that a board with any valid row/column/subgrid would return True. validate_<region> would …
gazoh's user avatar
  • 3,399
7 votes
Accepted

Magic 8 Ball program

I'd like to address how you handle the yes/no question controlling the loop. The relevant sections of your code are: again = 'yes' while again == 'yes': # [...] again = input('Are there any o …
gazoh's user avatar
  • 3,399
12 votes

Check if array has the same number of even and odd values in Python

There are a few optimizations that seem obvious to me, but the algorithm seems fine for what is does. if n % 2 != 0: return False if n % 2 == 0: # ... There is no need for the second if sta …
gazoh's user avatar
  • 3,399
7 votes

Print a list of license plate numbers of all cars that went over the speed limit, as well as...

However, max is a built-in function of python, that will no longer be accessible in your code. This can easily be avoided with a better variable name, such as speed_limit. …
gazoh's user avatar
  • 3,399
2 votes
Accepted

Nim in Pygame (Feedback plz)

This guide may seem a little superfluous, but having a consistent style makes your code easier to work with should you modify it and having your code follow the same style guide as mostly all python code …
gazoh's user avatar
  • 3,399
8 votes

ROT13 encryption using array indexing

Python conventions recommend docstrings for this kind of documentation. … Iterate on content, not on indices In Python, it is better practice on iterate on the content of an iterable rather than on indices. …
gazoh's user avatar
  • 3,399
3 votes

Simple console calculator

Project structure You divided your code in multiple modules and functions. While this is generally a good idea, I fail to understand the logic you used here. You should aim for each function to fully …
gazoh's user avatar
  • 3,399
2 votes
Accepted

Poker hand valuator in Python

This would make your code more consistent for everyone (including your future self) familiar with Python, and as such easier to work with and review. …
gazoh's user avatar
  • 3,399
2 votes
0 answers
217 views

Pillow plugin adding support for the QOI image format

Pillow is a popular library for handling images in Python. My code adds support for the QOI image format to Pillow. … An overview of the decoding/encoding process can be found in the Pillow docs: Writing Your Own File Codec in Python. …
gazoh's user avatar
  • 3,399

15 30 50 per page