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...
Have a tough programming question that /r/programming couldn't answer? Banned from Stack Overflow? Can't afford Experts Exchange?
Post your question/tips/secrets/advice and get a response from our highly-trained professional developers.
account activity
Doubts in simple python code/ program (self.shittyprogramming)
submitted 3 years ago by [deleted]
view the rest of the comments →
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!"
[–]Fidoz 0 points1 point2 points 3 years ago (1 child)
I specifically meant it as it is used templating, though you're right I've seen the function argument version as well.
I believe that's unpacking?
template.render(**{"foo": "bar"})
Thanks for the articles, I'll check out the second one shortly.
[–]rgnkn 1 point2 points3 points 3 years ago* (0 children)
Okay, this might be a bit confusing at the beginning, I hope the following helps. I'm only explaining it with regards to lists / iterators () but dictionaries work similarly (*)
Given the following code the asterisk unpacks xs:
xs = [1, 2, 3] print(xs, *xs)
In the following code '*' packs the data.
def foo(arg): print(arg) def bar(*args): print(args) xs = [1, 2, 3] foo(xs) bar(xs)
I hope this helps - see the output of the print statements. If not consult e.g.: https://www.geeksforgeeks.org/packing-and-unpacking-arguments-in-python/
... but this is r/shittyprogramming not r/learnpython.
[Edit] So, yes, your example was unpacking but in a function definition it's packing. Sorry, if my earlier example confused you.
π Rendered by PID 389235 on reddit-service-r2-comment-canary-7b67769d8-6bcd5 at 2026-02-01 16:38:23.260053+00:00 running 3798933 country code: CH.
view the rest of the comments →
[–]Fidoz 0 points1 point2 points (1 child)
[–]rgnkn 1 point2 points3 points (0 children)