Test 0 and false since false is 0

Terry Reedy tjreedy at udel.edu
Wed Jul 12 16:35:10 EDT 2017


On 7/12/2017 7:35 AM, Rhodri James wrote:
> On 12/07/17 03:29, Stefan Ram wrote:
>> Grant Edwards <grant.b.edwards at gmail.com> writes:
>>> False is required to be a singleton.
>>>> »singleton« usually means »the sole object of its class«.
>>>> »Ensure a class only has one instance, and provide a
>> global point of access to it.« - Gamma et al.

>>>>> type( False )
>> <class 'bool'>
>>>>>>> type( True )
>> <class 'bool'>
>>>> It seems, »False« is not a singleton under the
>> implementation of Python I used.
>> The point that was being made is that there are no other bools than True 
> and False, and they are distinct from the objects 1 and 0.

By analogy with 'singleton', True and False constitute a 'doubleton' in 
the sense of being the sole 2 objects of class Bool.
-- 
Terry Jan Reedy


More information about the Python-list mailing list

AltStyle によって変換されたページ (->オリジナル) /