question about True values

Max Erickson maxerickson at gmail.com
Wed Oct 25 22:30:58 EDT 2006


Steve Holden <steve at holdenweb.com> wrote:

> Gabriel Genellina wrote:
>> At Wednesday 25/10/2006 22:29, Terry Reedy wrote:
>> 
>>> >> the string class's "nil" value.  Each of the builtin types
>>> >> has such an "empty" or "nil" value:
>>> >>
>>> >>     string              ""
>>> >>     list                []
>>> >>     tuple               ()
>>> >>     dict                {}
>>> >>     int                 0
>>> >>     float               0.0
>>> >>     complex             0j
>>> >>     set                 set()
>>> >>
>>> >> Any other value besides the above will compare as "not
>>> >> false". 
>>> >>
>>> >
>>> > And today's question for the novices is: which Python type
>>> > did Skip 
>>> miss
>>> > from the above list?
>>>
>>> more that one:
>>>
>>> 0L
>>> decimal.Decimal(0) # is decimal.Decimal('0'), also
>>> u''
>>> array.array('c') # or any other typecode, I suspect, without
>>> initializer 
>> 
>> 
>> Just for fun:
>> buffer('')
>> frozenset()
>> iter(())
>> xrange(0)
>> 
> There's still a very obvious omission ...
> 
> regards
>   Steve

bool.

unicode and long if you are fussy.

max




More information about the Python-list mailing list