On 10/10/05, Nick Coghlan <[EMAIL PROTECTED]> wrote: > It also works for situations where "the first n items are mandatory, the rest > are optional". This usage was brought up in the context of a basic line > interpreter: > > cmd, *args = input.split()
That's a really poor example though. You really don't want a line interpreter to bomb if the line is empty! > Another usage is to have a Python function which doesn't support keywords for > its positional arguments (to avoid namespace clashes in the keyword dict), but > can still unpack the mandatory arguments easily: > > def func(*args, **kwds): > arg1, arg2, *rest = args # Unpack the positional arguments Again, I'd be more comfortable if this was preceded by a check for len(args) >= 2. I should add that I'm just -0 on this. I think proponents ought to find better motivating examples that aren't made-up. Perhaps Raymond's requirement would help -- find places in the standard library where this would make code more readable/maintainable. -- --Guido van Rossum (home page: http://www.python.org/~guido/) _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com