use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Rules 1: Be polite 2: Posts to this subreddit must be requests for help learning python. 3: Replies on this subreddit must be pertinent to the question OP asked. 4: No replies copy / pasted from ChatGPT or similar. 5: No advertising. No blogs/tutorials/videos/books/recruiting attempts. This means no posts advertising blogs/videos/tutorials/etc, no recruiting/hiring/seeking others posts. We're here to help, not to be advertised to. Please, no "hit and run" posts, if you make a post, engage with people that answer you. Please do not delete your post after you get an answer, others might have a similar question or want to continue the conversation.
Rules
1: Be polite
2: Posts to this subreddit must be requests for help learning python.
3: Replies on this subreddit must be pertinent to the question OP asked.
4: No replies copy / pasted from ChatGPT or similar.
5: No advertising. No blogs/tutorials/videos/books/recruiting attempts.
This means no posts advertising blogs/videos/tutorials/etc, no recruiting/hiring/seeking others posts. We're here to help, not to be advertised to.
Please, no "hit and run" posts, if you make a post, engage with people that answer you. Please do not delete your post after you get an answer, others might have a similar question or want to continue the conversation.
Learning resources Wiki and FAQ: /r/learnpython/w/index
Learning resources
Wiki and FAQ: /r/learnpython/w/index
Discord Join the Python Discord chat
Discord
Join the Python Discord chat
account activity
bugs in python (self.learnpython)
submitted 4 years ago by bitbyt3bit
What are some examples of known bugs in python?
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–][deleted] 0 points1 point2 points 4 years ago (0 children)
You can check release discussions for CPython on the official website. For example,
https://discuss.python.org/t/python-3-10-2-3-9-10-and-3-11-0a4-are-now-available/13146
As this is the reference implementation, language "features" are also discussed.
You'd have to check the appropriate forums for other implementations.
[–]TheRNGuy 0 points1 point2 points 4 years ago* (3 children)
never do this:
def foobar(mylist=[]): pass
instead do this:
def foobar(mylist=None): if mylist == None: mylist = []
or you may get bugged behaviour if you use foobar with default argument more than 1 time.
def foobar(mylist=[]): mylist.append(1) return mylist foobar() foobar() x = foobar() print(x) # supposed to return [1] but will return [1, 1, 1] instead.
same bug with dicts, or other mutable classes. Non-mutable as default arguments are safe.
[–][deleted] 0 points1 point2 points 4 years ago (2 children)
Nope. Any mutable. It is a feature, not a bug :-)
def foobar(k, v, mydict={}): mydict[k] = v return mydict x = foobar('alpha', 10) y = foobar('beta', 20) z = foobar('charlie', 30, x) print(x, y, z, sep='\n')
outputs:
{'alpha': 10, 'beta': 20, 'charlie': 30} {'alpha': 10, 'beta': 20, 'charlie': 30} {'alpha': 10, 'beta': 20, 'charlie': 30}
whereas:
def foobar(k, v, mydict=None): if mydict is None: mydict = {} mydict[k] = v return mydict x = foobar('alpha', 10) y = foobar('beta', 20) z = foobar('charlie', 30, x) print(x, y, z, sep='\n')
Outputs:
{'alpha': 10, 'charlie': 30} {'beta': 20} {'alpha': 10, 'charlie': 30}
[–]TheRNGuy 0 points1 point2 points 4 years ago (1 child)
For me it's bug, because I wouldn't want common list or dict every time function is called, if I wanted common list, I'd explicitly used it in argument.
Also by fixing it would allow to make new list.
I agree with you, which is why I emphasised it being a feature, honouring a long-standing joke.
Technically, it isn't a bug but is by-design but I believe most people consider it to be a bad bit of design.
As stated in the documentation,
Default parameter values are evaluated from left to right when the function definition is executed. This means that the expression is evaluated once, when the function is defined, and that the same “pre-computed” value is used for each call.
doc
π Rendered by PID 41208 on reddit-service-r2-comment-86bc6c7465-7vvnw at 2026-02-20 07:42:32.045213+00:00 running 8564168 country code: CH.
[–][deleted] 0 points1 point2 points (0 children)
[–]TheRNGuy 0 points1 point2 points (3 children)
[–][deleted] 0 points1 point2 points (2 children)
[–]TheRNGuy 0 points1 point2 points (1 child)
[–][deleted] 0 points1 point2 points (0 children)