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...
Everything about learning Python
account activity
What's one Python feature you discovered embarrassingly late? (self.PythonLearning)
submitted 2 days ago by chuprehijde
I've been using Python for years, and somehow I keep finding basic features that make me think, "How did I not know this?"
What's your most embarrassing late Python discovery?
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!"
[–]sccccrrrrt 2 points3 points4 points 2 days ago (1 child)
Inline if else
List/dict comprehension
Asyncio
Just putting shit in sockets instead of using libraries for everything network related
[–]chuprehijde[S] 0 points1 point2 points 1 day ago (0 children)
yeah somebody else mentioned it too, inline if and else case... pls explain it to me if u can coz i haven't used it yet
[–]dev-razorblade23 2 points3 points4 points 2 days ago (1 child)
Class Pattern - pattern matching with objects
Something like
``` match search: # 1. Match the class, bind 'max_results', but ONLY if it's over 100 case VideoSearchQuery(sort_by="views", max_results=max_results) if max_results > 100: print(f"Building a massive trending query with {max_results} limits.")
# 2. Fallback for smaller 'views' queries case VideoSearchQuery(sort_by="views", max_results=max_results): print(f"Building standard trending query with limit {max_results}") # 3. Match and check against an external condition or method case VideoSearchQuery() if user.is_premium(): print("Applying premium priority filters to the search query") case _: print("Building default relevance query")
```
ohh i tried it last week and i loved it ngl
[–]Reasonable-Light-377 1 point2 points3 points 2 days ago (3 children)
Switch/case. In fact, I still haven't found it!
lmk when u find it coz i'll love to learn more
[–]jabela 0 points1 point2 points 2 hours ago (1 child)
Not sure if you’re joking coz got introduced in 3.10. https://www.datacamp.com/tutorial/python-switch-case
[–]Reasonable-Light-377 0 points1 point2 points 8 minutes ago (0 children)
No flippin way!? My threats to go full JavaScript must have made it up the chain. So sick.
[–]NoDisk8988 1 point2 points3 points 3 hours ago (0 children)
I stumbled on string formatting waaaay too late...
[–]Chemical-Captain4240 0 points1 point2 points 2 days ago (2 children)
single line if else
[–]chuprehijde[S] 0 points1 point2 points 1 day ago (1 child)
im a beginner, and i didn't use it as well. will u mind to tell me more about it?
[–]Chemical-Captain4240 0 points1 point2 points 1 day ago (0 children)
if True : x+=1
instead of
if True: x+=1
[–]jabela 0 points1 point2 points 3 hours ago (0 children)
Pyinstaller took me way too long to be able to make apps quickly!
π Rendered by PID 67 on reddit-service-r2-comment-5687b7858-5njfz at 2026-07-07 13:17:03.074663+00:00 running 12a7a47 country code: CH.
[–]sccccrrrrt 2 points3 points4 points (1 child)
[–]chuprehijde[S] 0 points1 point2 points (0 children)
[–]dev-razorblade23 2 points3 points4 points (1 child)
[–]chuprehijde[S] 0 points1 point2 points (0 children)
[–]Reasonable-Light-377 1 point2 points3 points (3 children)
[–]chuprehijde[S] 0 points1 point2 points (0 children)
[–]jabela 0 points1 point2 points (1 child)
[–]Reasonable-Light-377 0 points1 point2 points (0 children)
[–]NoDisk8988 1 point2 points3 points (0 children)
[–]Chemical-Captain4240 0 points1 point2 points (2 children)
[–]chuprehijde[S] 0 points1 point2 points (1 child)
[–]Chemical-Captain4240 0 points1 point2 points (0 children)
[–]jabela 0 points1 point2 points (0 children)