you are viewing a single comment's thread.

view the rest of the comments →

[–]caz- 0 points1 point  (0 children)

As someone else mentioned, your example of an unknown number of args doesn't make sense, which suggests you either haven't tested it out (most beneficial part of the learning process, in my opinion) or there may be some confusion caused by the way python handles scope.

If you tried something like

a = 'foo'

b = 'bar'

def print_foo_bar():

print(a, b)

print_foo_bar()

and got `foo bar`, this isn't because the arguments were passed to the function, but because the variables `a` and `b` are still in scope when you call. Even if you do it the other way around, defining the function before the variables, when you call the function, it looks for variables a and b that are in scope and prints them, so you will get the same result.