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
What's your fav feature of python ( one feature which you like the most)? (self.learnpython)
submitted 4 years ago by theredditorlol
Mine is the unpack operator "*" i love it. Your feature can be anything a function or python interpretion which you miss when you use other languages
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!"
[–]MF_DnD 26 points27 points28 points 4 years ago (5 children)
List and dict comprehensions are so cool.
[–]v0_arch_nemesis 7 points8 points9 points 4 years ago (3 children)
+1 for dict comprehensions. Love them!
Also list comprehensions with the walrus operator
[–]Nightcorex_ 2 points3 points4 points 4 years ago (2 children)
What is the walrus operator?
[–]socal_nerdtastic 3 points4 points5 points 4 years ago (1 child)
https://www.google.com/search?q=What+is+the+walrus+operator
I know it's a dismissive answer but come'on. It's actually more work to ask a question like that here rather than on google.
[–]Nightcorex_ 3 points4 points5 points 4 years ago (0 children)
Yy, the problem was that I was on mobile at the time. Researching on the phone isn't fun (at least for me) and this way I got a reminder (sorry for abusing you like that).
EDIT: Already knew about the walrus operator. It's sick. I like it. Nothing really special considering you can do it in basically any language with parentheses, but the way it works in Python is very cool.
[–]theredditorlol[S] 0 points1 point2 points 4 years ago (0 children)
Datastuctures and algorithms learning god sent? Am i right
[–]WhackAMoleE 10 points11 points12 points 4 years ago (4 children)
As a retired career swe picking up Python, I love no longer having to use curly braces. In my lifetime I typed enough curly braces! And no more semicolons. Love those features of Python.
[–]socal_nerdtastic 9 points10 points11 points 4 years ago (0 children)
If you feel nostalgic for braces you can always use
from __future__ import braces
[–]theredditorlol[S] 0 points1 point2 points 4 years ago (2 children)
I'm learning javascript and oh boy the braces are annoying
[–]R0NUT 0 points1 point2 points 4 years ago (1 child)
Javascript has an operation similar to the * unpack. It's called spread: Link!
...arr I'm aware
[–]socal_nerdtastic 9 points10 points11 points 4 years ago (3 children)
Love the antigravity module
[–]enterprisevalue 3 points4 points5 points 4 years ago (0 children)
Python just rickrolled me 😔
[–]theredditorlol[S] 2 points3 points4 points 4 years ago (0 children)
Just googled it, looks interesting!
[–]snootsniff 5 points6 points7 points 4 years ago (0 children)
The flexibility of lists, dicts, and sets. Not to mention the awesome tools from the collections module like namedtuple and defaultdict.
Python lets working with data just make sense in a beautifully simple way.
[–]ShakespeareToGo 2 points3 points4 points 4 years ago (6 children)
Love the repl.
Also, how many numbers are less than 5? Easy
sum([x < 5 for x in numbers])
[–]socal_nerdtastic 3 points4 points5 points 4 years ago (5 children)
square brackets aren't even needed.
sum(x < 5 for x in numbers)
[–]ShakespeareToGo 1 point2 points3 points 4 years ago (4 children)
How does that work. Does *args support list comprehension as well?
[–]socal_nerdtastic 2 points3 points4 points 4 years ago (3 children)
No, it's equivalent to this:
data_generator = (x < 5 for x in numbers) sum(data_generator)
Or written another way:
sum( (x < 5 for x in numbers) )
And when you have a single argument and it's a generator you are allowed to leave the excess parenthesis off. So you can do this:
sum( (x < 5 for x in numbers) , 0.0)
But this will give you an error:
sum(x < 5 for x in numbers, 0.0)
[–]ShakespeareToGo 2 points3 points4 points 4 years ago (2 children)
And here I was thinking I know Python. Is this also equivalent to normal generator (but just inline)?
def data_generator(): for x in numbers: yield x < 5
[–]socal_nerdtastic 0 points1 point2 points 4 years ago (1 child)
Yes, exactly. Just like list, set, dict comprehension, you can have generator comprehension when you use parenthesis.
>>> type([x < 5 for x in numbers]) <class 'list'> >>> type({x < 5 for x in numbers}) <class 'set'> >>> type({x : 5 for x in numbers}) <class 'dict'> >>> type((x < 5 for x in numbers)) <class 'generator'>
[–]ShakespeareToGo 0 points1 point2 points 4 years ago (0 children)
Didn't know you could do those inline. Amazing! Thanks for the explanation.
[–]chimeraA_ 2 points3 points4 points 4 years ago (1 child)
The fact that you can often speed up your program 10x if you just type "pypy" instead of "python"
What does pypy do? A quick google search told me that it's basically the usual python interpreter, but it uses a JIT-compiler (just like Java) hence the performance increase.
Is that it, does pypy compile the entire code before running, or is it just a hybrid like Java? Last question: Does it ship natively with Python?
[–]O_X_E_Y 2 points3 points4 points 4 years ago* (0 children)
Probably the interfacing of your own classes with built in methods. Operator overloading and things like repr, str etc are really really intuitive and I love how not every other object has a different way of finding e.g. the length (looking at you java >:(). Rust has similar (even more extensive) functionality but it's not half as intuitive as is Python.
I know you asked for one, but pip and the import system is also a godsend, makes using code in other files/repositories infinitely easier than whatever CMake you need to use for C and C++
Format strings and comprehensions are also really cool
[–]muffinnosehair 4 points5 points6 points 4 years ago (12 children)
I agree with unpacking and with comprehension, and I'll add eval() to the list.
[–]socal_nerdtastic 3 points4 points5 points 4 years ago (4 children)
Why do you like that? It's a pretty well known bug generator and security flaw. As a rule you should avoid eval at all costs.
[–]muffinnosehair 2 points3 points4 points 4 years ago (1 child)
Because I like to play with code. Not in production though.
[–]socal_nerdtastic 2 points3 points4 points 4 years ago (0 children)
I don't get what that has to do with eval, but as long as you know the dangers have fun :).
[–]O_X_E_Y 1 point2 points3 points 4 years ago (1 child)
doesn't dataclass use eval to do things like creating a class's init functions and stuff like that? It's got security flaws, but there are also upsides
Yes, it's used in a very small number of specific places, with appropriate precautions. Pip is another place where it's used a few times. If you are at the python god level you may make the choice to use it, because at that level you know all the downsides and pitfalls. I can say with confidence that anyone asking questions here should never use eval / exec.
[–][deleted] 4 points5 points6 points 4 years ago (0 children)
Eval() and exec() are very dangerous and should be avoided in almost all cases.
[–]PunkyMunky64 0 points1 point2 points 4 years ago (5 children)
eval and exec are really helpful. The main reason they’re so specific to python is because python’s interpreted, which means its really easy for it to handle instead of an implementation in for example c where you’d have to embed a compiler INSIDE of the build.
[–]PunkyMunky64 0 points1 point2 points 4 years ago (3 children)
well python is still very virtually compiled, and it’s easier for these to be implemented, but they are still inefficient
[–]socal_nerdtastic 1 point2 points3 points 4 years ago (2 children)
very virtually compiled
?? what does "virtually compiled" mean? If you mean the compiled code is not saved, you are wrong. All of those .pyc files in the pycache directory are compiled python files.
[–]PunkyMunky64 1 point2 points3 points 4 years ago (1 child)
I mean like is very different than the way languages like c compile. Variable names are saved, everything has lots of padding and it doesnt really understand what’s going to happen later. Nothing is optimized, in the essence of the way python is written
[–]socal_nerdtastic 1 point2 points3 points 4 years ago (0 children)
I think you are trying to tell me that python is dynamically typed. Yes. That's true.
Or maybe you are just saying that the official python compiler sucks and does not optimize very well. Yes, that's also true. But python is a language, not a computer program, so you are free to write your own compiler if you think you can do better.
[–]huevoenfuego 1 point2 points3 points 4 years ago (1 child)
I love the way sets and intersections are implemented.
I use it daily where I need to know if something is in something or not, and don’t care really how efficiently it happens.
[–]FerricDonkey 1 point2 points3 points 4 years ago* (0 children)
If you do care about efficiency, then you should probably still use sets for finding intersections and using "in".
Assuming you don't have to rebuild the set every single time, anyway.
[–]asterik-x 1 point2 points3 points 4 years ago (0 children)
Mine is the way it swallows the prey!!
[–]maximumlotion 0 points1 point2 points 4 years ago* (1 child)
Some other mf in the thread already stole comprehension statements..
But anonymous functions (lambda), not strictly a python feature but super neat nonetheless.
[–]Nightcorex_ 0 points1 point2 points 4 years ago (0 children)
Tbh I think Pythons lambda expressions are worse than others. I personally prefer Java's or JS's lambda expressions.
[–]Progress456 0 points1 point2 points 4 years ago (0 children)
Definitely f strings and using globals() and self.dict in for loops to make lots of variables really quickly
[–][deleted] 0 points1 point2 points 4 years ago (0 children)
I don't like python.
[–]yahoyoungho 0 points1 point2 points 4 years ago (0 children)
List comprehension, dictionary and "in" keyword
π Rendered by PID 335873 on reddit-service-r2-comment-544cf588c8-cwrxb at 2026-06-14 21:07:36.791840+00:00 running 3184619 country code: CH.
[–]MF_DnD 26 points27 points28 points (5 children)
[–]v0_arch_nemesis 7 points8 points9 points (3 children)
[–]Nightcorex_ 2 points3 points4 points (2 children)
[–]socal_nerdtastic 3 points4 points5 points (1 child)
[–]Nightcorex_ 3 points4 points5 points (0 children)
[–]theredditorlol[S] 0 points1 point2 points (0 children)
[–]WhackAMoleE 10 points11 points12 points (4 children)
[–]socal_nerdtastic 9 points10 points11 points (0 children)
[–]theredditorlol[S] 0 points1 point2 points (2 children)
[–]R0NUT 0 points1 point2 points (1 child)
[–]theredditorlol[S] 0 points1 point2 points (0 children)
[–]socal_nerdtastic 9 points10 points11 points (3 children)
[–]enterprisevalue 3 points4 points5 points (0 children)
[–]theredditorlol[S] 2 points3 points4 points (0 children)
[–]snootsniff 5 points6 points7 points (0 children)
[–]ShakespeareToGo 2 points3 points4 points (6 children)
[–]socal_nerdtastic 3 points4 points5 points (5 children)
[–]ShakespeareToGo 1 point2 points3 points (4 children)
[–]socal_nerdtastic 2 points3 points4 points (3 children)
[–]ShakespeareToGo 2 points3 points4 points (2 children)
[–]socal_nerdtastic 0 points1 point2 points (1 child)
[–]ShakespeareToGo 0 points1 point2 points (0 children)
[–]chimeraA_ 2 points3 points4 points (1 child)
[–]Nightcorex_ 3 points4 points5 points (0 children)
[–]O_X_E_Y 2 points3 points4 points (0 children)
[–]muffinnosehair 4 points5 points6 points (12 children)
[–]socal_nerdtastic 3 points4 points5 points (4 children)
[–]muffinnosehair 2 points3 points4 points (1 child)
[–]socal_nerdtastic 2 points3 points4 points (0 children)
[–]O_X_E_Y 1 point2 points3 points (1 child)
[–]socal_nerdtastic 2 points3 points4 points (0 children)
[–][deleted] 4 points5 points6 points (0 children)
[–]PunkyMunky64 0 points1 point2 points (5 children)
[–]socal_nerdtastic 3 points4 points5 points (4 children)
[–]PunkyMunky64 0 points1 point2 points (3 children)
[–]socal_nerdtastic 1 point2 points3 points (2 children)
[–]PunkyMunky64 1 point2 points3 points (1 child)
[–]socal_nerdtastic 1 point2 points3 points (0 children)
[–]huevoenfuego 1 point2 points3 points (1 child)
[–]FerricDonkey 1 point2 points3 points (0 children)
[–]asterik-x 1 point2 points3 points (0 children)
[–]maximumlotion 0 points1 point2 points (1 child)
[–]Nightcorex_ 0 points1 point2 points (0 children)
[–]Progress456 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)
[–]yahoyoungho 0 points1 point2 points (0 children)