Python *args: Accepting any number of positional arguments

Python *args: Accepting any number of positional arguments

Want your Python function to take any number of positional args? Use *args:

– Can be any name, but args is traditional
– The * is only in the function definition
– It’s a tuple
– Don’t grab elements by index; iterate over them
– It might be empty
– Pronounce it “splat args”