Reverse argument order
Bengt Richter
bokr at accessone.com
Sat Oct 20 17:53:52 EDT 2001
On Fri, 19 Oct 2001 14:59:19 -0700 (PDT), David Brady <daves_spam_dodging_account at yahoo.com> wrote:
>Thanks, everyone, for your answers. Also, thanks to
>those of you that ways of asking if the question
>really needed to be asked.
>
>At the time I had posted, we had considered all of the
>non-answer answers that were posted here. Most were
>rejected by the business half of the team, because
>they have a goal of reducing the keystroke count as
>much as possible. They're already upset that the new
>scripting language has to have parentheses everywhere.
> :-)
>
>Specifically,
>
>We considered using named arguments, but rejected them
>because even typing Wait(m=3,s=10) was judged to be
>too hard, let alone Wait(minutes=3, seconds=10).
>Personally, I like this approach best, and I want to
>just write in the manual, "Look, you're going to have
>to learn to type, okay?" But that's just me.
>
>We also considered using Wait(0,0,5) for a 5-second
>wait, but this was also shot down.
>
>One possible compromise was offered by the business
>half of the team, that they would be willing to type
>Wait(,,5), but *WE* shot that down on the grounds that
>it does not work. (They were thinking it would
>evaluate to Wait(None,None,5) which could then have
>been turned into 0,0,5).
>
>We considered the string bit, but strings require
>quotes....
>
>We even considered modifying the Python source so that
>it would accept 00:00:00 as a token identifying a time
>type (that we would add). This was discarded by
>everyone as WAY too much effort. (Imagine getting the
>lexer to accept things like "while t < 1:05: pass")
>
>Anyway, thank you all again for your answers and help.
> This project is starting to shape up!
>
>-dB
>P.S. We're going to go with the "while len(args)<3:
>args.insert(0,0)" model for now. Much less sucky,
>yes, thanks!
>
>=====
Brute force, but clear:
>>> def wait(first=None,second=None,third=None):
... if third: h,m,s = first,second,third
... elif second: h,m,s=0,first,second
... elif first: h,m,s=0,0,first
... else: h,m,s=0,0,0
... print "h=%d, m=%d, s=%d" % (h,m,s) # or whatever you want to do
...
>>> wait()
h=0, m=0, s=0
>>> wait(1)
h=0, m=0, s=1
>>> wait(1,2)
h=0, m=1, s=2
>>> wait(1,2,3)
h=1, m=2, s=3
More information about the Python-list
mailing list