On 10-Apr-11 12:21 PM, Mel wrote:
Chris Angelico wrote:
Who would use keyword arguments with a function that takes only one arg
anyway?
It's hard to imagine. Maybe somebody trying to generalize function calls
(trying to interpret some other language using a python program?)
# e.g. input winds up having the effect of ..
function = bool
name = 'x'
value = 'the well at the end of the world'
## ...
actions.append ((function, {name:value}))
## ...
for function, args in actions:
results.append (function (**args))
Not something I, for one, do every day. But regularity in a language is
good when you can get it, especially for abstract things like that.
I can sort of guess that `dir` was perhaps coded in C for speed and doesn't
spend time looking for complicated argument lists.
Python is a pragmatic language, so all the rules come pre-broken.
Mel.
This thread has lasted 3 days so far.
I presume that it is agreed they the following is a satisfactory outcome:
*** Python 2.7.1 (r271:86832, Nov 27 2010, 18:30:46) [MSC v.1500 32 bit
(Intel)] on win32. ***
>>> bool(x=0)
False
>>> bool(x=1)
True
>>>
Colin W.
--
http://mail.python.org/mailman/listinfo/python-list