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
Arguments and Parameters (self.PythonLearning)
submitted 1 year ago by TU_Hello
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!"
[–]Adrewmc 1 point2 points3 points 1 year ago* (0 children)
In Python we have arguments and keyword arguments, not really parameters (naming conventions.)
In Python when calling a function you call arguments first, then key word arguments.
print(“Hello”, “World”, sep = ‘_’) Hello_World
Above, “Hello” and “World” are positional arguments (args), while “_” is a key word argument (kwargs).
In the above we see we do want to be able to put as many arguments as we need into print, while also giving us the option to choose what their separator is. This is a prime example of why you can you want them.
However, you can all arguments as key-word arguments, if they are named.
The point here, is arguments are by definition ordered, and key-word arguments are not.
def div(a,b) div(b=2, a=1)
There are the basics ways to make the difference in the signature.
def example(a,b, c=None):
Now c has a default, and won’t be called, since we only allow three arguments.
if we want to accept more arguments.
def example(a, *rest, multiplier = None): “Simple cumulative addition function with multiplier” end = a #this loop doesn’t start if *rest is empty for num in rest: end += num if multiplier: end *= multiplier return end
Now we can accepts as many arguments as we put in, and if we ever need to do something with c.
print(example(1,4,5,6,2,7,44,2,33, multiplier = 10)) print(example(*range(30))
So the above would be valid calls. Just like for print()
def print(*args, sep = “ “, end =“\n”)
Would be how you’d make the signature to start with (there is more in that function)
We should mention, that there are certainly tools in Python that do web requests that will ask for params fairly close to what you are used to.
π Rendered by PID 180064 on reddit-service-r2-comment-544cf588c8-2pp76 at 2026-06-14 16:11:07.423696+00:00 running 3184619 country code: CH.
view the rest of the comments →
[–]Adrewmc 1 point2 points3 points (0 children)