[Tutor] am I missing another simpler structure?
glingl at aon.at
Thu Dec 16 14:57:32 CET 2004
Kent Johnson schrieb:
> It's probably worth pointing out that these two functions are not
> entirely equivalent:
> def t1():
> if condition:
> return True
> return False
> def t2():
> return condition
> >>> if t1(100) == True: print '100 is True'
> 100 is True
> >>> if t2(100) == True: print '100 is True'
> (nothing prints)
If you really need this property, you may use
type-conversion with bool:
So in this case
should work correctly
Remark for Brian: Please note, that Kent wrote about a feature
specific to Python, whereas the main part of this thread
contains considerations concerning boolean expressions in general.
More information about the Tutor