On 10/10/05, Nick Coghlan <ncoghlan at gmail.com> 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/)
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4