Style question (Poll)

Prasad, Ramit ramit.prasad at jpmorgan.com
Thu Mar 15 00:08:17 CET 2012


> > Only use 'is' if you are looking for objects like True,
> > False, None or something that MUST be exactly the same object.
> 
> I've rarely seen valid uses of 'is True' or 'is False'.

It can be useful when you think something might be None or False. Although,
I suppose you could always just use 'is None' instead.

>>> 1 == True
True
>>> 1 is True
False
>>> 0 == False
True
>>> 0 is False
False

Granted, the above example is a pretty facetious case; not sure I 
can come up with a reasonably real world use case. 

Ramit


Ramit Prasad | JPMorgan Chase Investment Bank | Currencies Technology
712 Main Street | Houston, TX 77002
work phone: 713 - 216 - 5423

--


This email is confidential and subject to important disclaimers and
conditions including on offers for the purchase or sale of
securities, accuracy and completeness of information, viruses,
confidentiality, legal privilege, and legal entity disclaimers,
available at http://www.jpmorgan.com/pages/disclosures/email.  


More information about the Python-list mailing list