Using both keyword=something and *unknownqty arguments in a function
David Eppstein
eppstein at ics.uci.edu
Mon Dec 22 20:06:40 EST 2003
More information about the Python-list mailing list
Mon Dec 22 20:06:40 EST 2003
- Previous message (by thread): Using both keyword=something and *unknownqty arguments in a function
- Next message (by thread): Counting how many chars equal to a given char are in the beginning of a string
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
In article <vuf0da834iuc2a at corp.supernews.com>, "Francis Avila" <francisgavila at yahoo.com> wrote: > >def skeptic(first='Zeus', second='Guido', *others) > > print first > > print second > > print others > > return "and I did not think it could ever work!" I think there is not so much problem mixing keyword=something and *unknownqty, as long as you do not also allow named positional arguments. def skeptic(*others, **keywords): print keywords['first'] print keywords['second'] print others return "and I did not think it could ever work!" >>> answer=skeptic('believer', 'non-believer', 'heretic', first='Eric', second='unknown') Eric unknown ('believer', 'non-believer', 'heretic') >>> answer 'and I did not think it could ever work!' -- David Eppstein http://www.ics.uci.edu/~eppstein/ Univ. of California, Irvine, School of Information & Computer Science
- Previous message (by thread): Using both keyword=something and *unknownqty arguments in a function
- Next message (by thread): Counting how many chars equal to a given char are in the beginning of a string
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list