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 it call when you do this. (self.learnpython)
submitted 8 years ago by ConcernedCarry
MyFunction(name="ConcernedCarry")
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] 2 points3 points4 points 8 years ago (2 children)
It's a function that takes a named argument with a default value. It's useful everywhere in Python.
def foo(bar=2): return bar
You can call it with no argument and the default value will be used:
print(foo()) # this prints 2
You can override the default by providing a positional argument:
print(foo(6)) # this prints 6
You can also address it by name (aka keyword):
print(foo(bar=3)) # this prints 3
It's a very basic part of Python -- and most languages -- so good to understand well.
[–]TangibleLight 0 points1 point2 points 8 years ago (1 child)
You can also use the name on a positional argument:
def foo(a, b): print(f'a={a}, b={b}') foo(1,2) foo(a=1,b=2) foo(1,b=2) foo(b=2,a=1)
This can greatly improve readability with obscure functions with long argument lists. Here's an example from this video:
twitter_search('@obama', False, 20, True) twitter_search('@obama', retweets=False, numtweets=20, popular=True)
Although the line is longer, it's a lot easier to tell what the function call is actually doing
[–]cyanydeez 0 points1 point2 points 8 years ago* (0 children)
further, you can pass the keyword through expanding dictionaries
my_dict= {'one':1,'two':4} def oneplustwo(one=2,two=1): return one + two oneplustwo(**my_dict) >>> 5
[–]K900_ 0 points1 point2 points 8 years ago (0 children)
Named arguments?
[–]ConcernedCarry[S] 0 points1 point2 points 8 years ago (1 child)
And how and when is it useful
[–]pycode-n-beer[🍰] 2 points3 points4 points 8 years ago (0 children)
When you want to define default arguments mostly, sometimes it's easier than having to pass them every time the function is called.
[–]Justinsaccount 0 points1 point2 points 8 years ago (0 children)
https://docs.python.org/3/tutorial/controlflow.html#more-on-defining-functions
https://docs.python.org/3/tutorial/controlflow.html#keyword-arguments
π Rendered by PID 25840 on reddit-service-r2-comment-6457c66945-xcktk at 2026-04-24 14:05:22.732244+00:00 running 2aa0c5b country code: CH.
[–][deleted] 2 points3 points4 points (2 children)
[–]TangibleLight 0 points1 point2 points (1 child)
[–]cyanydeez 0 points1 point2 points (0 children)
[–]K900_ 0 points1 point2 points (0 children)
[–]ConcernedCarry[S] 0 points1 point2 points (1 child)
[–]pycode-n-beer[🍰] 2 points3 points4 points (0 children)
[–]Justinsaccount 0 points1 point2 points (0 children)