Argument of the bool function
lie.1296 at gmail.com
Sat Apr 9 07:45:38 CEST 2011
On 04/09/11 08:59, candide wrote:
> Le 09/04/2011 00:03, Ethan Furman a écrit :
>> > bool([x])
>> > Convert a value to a Boolean, using the standard truth testing
>> > procedure.
>> As you can see, the parameter name is 'x'.
> OK, your response is clarifying my point ;)
> I didn't realize that in the bool([x]) syntax, identifier x refers to a
> "genuine" argument [I was considering x as referring to a "generic"
> object having a boolean value].
> Nevertheless, compare with the definition the doc provides for the
> builtin function dir():
> [definition omited, just observe the declaration syntax]
> Now, lets make a try
>>>> dir(object="Explicit is better than implicit")
> Traceback (most recent call last):
> File "<stdin>", line 1, in <module>
> TypeError: dir() takes no keyword arguments
> Not very meaningful, isn't it ?
The error says it unambiguously, dir() does not take *keyword*
arguments; instead dir() takes *positional* argument:
dir("Explicit is better than implicit")
More information about the Python-list