Search Results
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 |
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.
2
votes
Accepted
Tracking current during iteration
It's too bad your template engine doesn't support conditions. What about this?
def marked_active_post(orig_posts, active_index):
posts_view = orig_posts.deepcopy()
posts_view[active_index]['a …
5
votes
Accepted
Static blog generator
(The code looks great, I still tried to provide helpful suggestions.)
I use single source file to make it easier to distribute
Why would a single .py file be easier to distribute? We have lots o …
3
votes
Prefix free compression and decompression
Great job, this code does a lot of things in few lines, is easy to read, and the results are quite impressive. But who's going to upvote me if only say this?
One general comment: this is not Python, …
3
votes
Python logging handler
You simply need to understand what's going on when you write:
logging.basicConfig(format=LOG_FORMAT,
level="NOTSET",
stream=Devnull(),
…
4
votes
Organization of complex empirical equations
These models tend to be quite complicated.
Maybe that's standard in your field, but they definitely are complicated, and converting those equations into code will never be pretty (I'm looking at …
1
vote
Verlet integration movement - doubt for on_key_press() methods
def handler(self):
'''
Calls Player on_x_key_pressed(), on_x_key_released()
methods according to event bools set from the listener method.
'''
# Moving
…
2
votes
Accepted
Representation of an artificial neuron
I have started to interest myself in artificial intelligence a while ago, especially within the game industry. I have started with state machines moved on to fuzzy logic and now I want to learn and …
4
votes
Printing a rectangle
It makes little sense to have a variable c that always contains 'c'.
Simply replace c by 'c' in your print call.
Learn about PEP8 and about checking that your code conforms to PEP8. A few things to c …
3
votes
Accepted
Securely convert and return a user selected file
This script is insecure because there are a few small issues. And such issues can often be combined to produce bigger issues, so it's important to be wary about them.
First, you're not restricting th …
4
votes
Extract Pages from PDF based on search in python
You could try profiling but the code is simple enough that I think you're spending most of the time in PyPDF2 code. Two options:
You can preprocess your PDF files to store their text somewhere, whic …
4
votes
Accepted
Silly Caesar encryption in Python
Let's start with a few things that will make your code way better:
Use docstrings, not # for comments.
Use a PEP 8 checker such as pycodestyle or flake8
The way you handle input and options is cleve …
3
votes
Python Prime Testing
Congratulations, you just came up with a prime sieve! And indeed, it's faster than always considering all the multiples of 2 of 3. But why do you stop at multiples of 2 and 3? What about 5? And 7? But …
2
votes
Managing python application configuration in a key-value store
Thanks for the interesting question.
Since you already have an answer focusing on the code itself, I'll focus more on the high-level bits.
Why Consul?
First, as you noted, containers bring many ben …
2
votes
Accepted
The YouTube crawler
from tkinter import *
Importing everything from a module is generally frowned upon because it hampers readability, can cause confusion ("where does Label come from?") and breaks useful tools like py …
7
votes
Reading a repetitive file with repetitive code
Well, why not use a loop?
for i in range(13):
next(f)
You should also use constants instead of magic numbers, like this:
LINES_BETWEEN_SIGN_AND_DATA = 13
for i in range(LINES_BETWEEN_SIGN_AND …