Argument of the bool function
mwilson at the-wire.com
Fri Apr 8 18:42:22 CEST 2011
> About the standard function bool(), Python's official documentation
> tells us the following :
> Convert a value to a Boolean, using the standard truth testing procedure.
> In this context, what exactly a "value" is referring to ?
> For instance,
> >>> x=42
> >>> bool(x=5)
Cute. What's happening here is that `x=5` isn't really an expression.
It's passing a value to the named parameter `x`, specified in the
definition of `bool`. Try it with something else:
Python 2.6.5 (r265:79063, Apr 16 2010, 13:09:56)
[GCC 4.4.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: 'y' is an invalid keyword argument for this function
More information about the Python-list