index & value (was Re: inclusive-lower-bound, exclusive-upper-bound (was Re: Range Operation pre-PEP))
aleaxit at yahoo.com
Tue May 15 10:05:55 CEST 2001
"Quinn Dunkan" <quinn at retch.ugcs.caltech.edu> wrote in message
news:slrn9g0v90.kg2.quinn at retch.ugcs.caltech.edu...
> Do methods that take an index and a value use the order 'index, value', or
> 'value, index'? Standard eiffel is 'value, index', but standard python is
> 'index, value'. I prefer python, but can't articulate why.
Well, if the argument that comes later is the one that can
be defaulted, I think the Python style is better -- you're
more likely to want to default the value than the index.
returning None if akey is not in mydict, with
returning 23 in that case.
If default-valued arguments are not allowed, there may
still be a small stylistic advantage to index-first in
consistency between different but 'similar' methods:
I.e., there may be methods that ONLY accept the index
(so that having the index always first is consistent --
it's gotta be first if it's the only argument:-), more
likely than methods that only accept the value (not that
the latter case is impossible -- just less prevalent).
More information about the Python-list