Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #35653
| References | <92097A6A775D5147B1078E3F15430B9234A0F238@prato.activenetwerx.local> <CALwzidmKXuHmGWMAoJbeiCxmPpmqd1tvAVxDuZZTAzL0TbgC_A@mail.gmail.com> <assp.07088be20f.92097A6A775D5147B1078E3F15430B9234A0F2BA@prato.activenetwerx.local> |
|---|---|
| Date | 2012-12-27 21:07 +0000 |
| Subject | Re: Function Parameters |
| From | Oscar Benjamin <oscar.j.benjamin@gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.1369.1356642448.29569.python-list@python.org> (permalink) |
On 27 December 2012 20:47, Joseph L. Casale <jcasale@activenetwerx.com> wrote: >> Don't use kwargs for this. List out the arguments in the function >> spec and give the optional ones reasonable defaults. > >> I only use kwargs myself when the set of possible arguments is dynamic >> or unknown. > > Gotch ya, but when the inputs to some keywords are similar, if the function is called > with two of three (which is valid) and the arg name isn't used, the assignment is order > dependent and arbitrary in a sense and I can not distinguish. > > It would be nice if you could force the keyword to be mandatory to forgo the assumption > in assignment like kwargs provides with gets. I suppose all the time wasted here is in vain > as the caller could blunder elsewhere... In Python 3 you can do this using keyword-only arguments like so (note the asterisk that separates keyword arguments from positional arguments): def my_func(self, *, some_key=MISSING, another_key=MISSING): Oscar
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: Function Parameters Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2012-12-27 21:07 +0000
csiph-web