[Tutor] Don't understand this class/constructor call syntax
Wayne Werner
waynejwerner at gmail.com
Sun Jul 24 14:34:54 CEST 2011
On Sun, Jul 24, 2011 at 2:07 AM, Steven D'Aprano <steve at pearwood.info>wrote:
> (Note that among strings, only the empty string counts as nothing. The
> strings 'nothing', 'empty', 'false', 'not a thing', 'nada', 'not a brass
> farthing', "dry as a dingo's donger" etc. are non-empty strings and
> therefore count as true-values.)
>
Though just for completeness sake, you could do something like:
def mytest(string):
if string.lower() in ("nothing", "empty", "false", "not a thing",
"nada", "not a brass farthing", "dry as a dingo's donger"):
return False
else:
return True
if you were really interested in using values such as those.
Personally, just for kicks and giggles, when I write personal programs and I
ask for "Y/N" input, I'm fairly liberal - so instead of N you could input N,
No, nyet, no way, no thanks... you get the picture.
My 1 cent and pocket lint,
-Wayne
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20110724/bfaced0c/attachment.html>
More information about the Tutor
mailing list