[x-post from r/java] What Python concepts beyond the absolute basics should every developer have a excellent understanding of?
posted over here on /r/java.
So, what should they really know their way around?
15 comments · 72% upvoted · other discussions
Depends on how you define "absolute basics".
Some really useful things to know whether they fall under that umbrella or not:
```
unpack a list into a function accepting an arbitrary number of arguments
a = [1, 2, 3] some_function(*a) # same as some_function(1, 2, 3)
unpack a Dict into a function accepting arbitrary keyword arguments
kwa = {'a': 1, 'b': 2, 'c': 3} some_function(**kwa) # same as some_function(a=1, b=2, c=3)
unpack a list of items into separate variables
item_0, item_1 = [1, 2] item_0 # value is 1 item_1 # value is 2 ```
tilkau 3 points · Nov 2018
Github triple-backtick code blocks aren't supported by reddit. Instead you need to prepend 4 spaces to each line in the code block. This would also fix a problem that looks like your comment lines are being parsed as headings.
The latter half of your list is also messed up, you probably need an additional newline to trigger list formatting (so the list looks like it is beginning a new paragraph, not 'touching' any other text). That happens to me a lot.
theywouldnotstand 2 points · Nov 2018
Shows fine on the Reddit mobile app, fancy that.
And in fact, when I edit it to your suggestion, it is all messed up on the mobile app
Only place I see what you describe is the mobile version of the site in a browser. ¯\_(ツ)_/¯
[deleted] 1 points · Nov 2018
[deleted]
lalligood 1 points · Nov 2018
Although syntactically very similar to list/dict/set comprehensions, I would suggest including generators. Visually the only difference is that generators are framed in parens vs square brackets or curly brackets, but it's knowing when to use a generator vs a comprehension & why generators can be better when used properly (read: drastically reduced memory requirements).
theywouldnotstand 1 points · Nov 2018
Don't forget using
yieldin a function to produce a more complex generator as well.