Is there a simpler way to modify all arguments in a function before using the arguments?

Chris Angelico rosuav at gmail.com
Sat Nov 10 13:33:58 EST 2012


On Sun, Nov 11, 2012 at 12:15 AM,  <bruceg113355 at gmail.com> wrote:
> Thanks to all.
> Steve's example is the one I will try next week.
> Passing in lists, will work but it requires extra coding from the calling routines to build the list.

Not necessarily! Watch:

def foo(*args):
    print(repr(args))

foo("Hello","world","!")

('Hello', 'world', '!')

Okay, that's not technically a list, it's a tuple, but same diff. Your
callers still see you as taking separate arguments, but you take them
as a single collection.

ChrisA



More information about the Python-list mailing list