Writing a string.ishex function
D'Arcy J.M. Cain
darcy at druid.net
Thu Jan 14 15:29:40 EST 2010
On Thu, 14 Jan 2010 18:36:12 +0000
MRAB <python at mrabarnett.plus.com> wrote:
> > print ishex('123') is True
> > print ishex('abc') is True
> > print ishex('xyz') is False
> > print ishex('0123456789abcdefABCDEF') is True
> > print ishex('0123456789abcdefABCDEFG') is False
> >
> Don't use 'is', use '=='.
Why? There is only one True and one False in Python. Is it a style
issue for you? If so then say "shouldn't" not "don't."
--
D'Arcy J.M. Cain <darcy at druid.net> | Democracy is three wolves
http://www.druid.net/darcy/ | and a sheep voting on
+1 416 425 1212 (DoD#0082) (eNTP) | what's for dinner.
More information about the Python-list
mailing list