Empty string is False right?
Steve Holden
steve at holdenweb.com
Sat Jan 31 08:27:20 EST 2009
AJ Ostergaard wrote:
> I'm not suggesting it's not operating as advertised - I'm suggesting the
> 'advertising' is slightly sguiffy if you catch my drift. I guess it's
> just me that finds it slightly counter intuitive. Surely intuitively the
> expression is "and" and therefore should always return a boolean?
>
> I'll shut up now. ;)
>
You might think so, and it wouldn't be an entirely unreasonable thought,
but in practice it makes a lot of sense to retain the original value
where possible.
The fact is that any left-hand operand that evaluates to false in a
Boolean context can be used as it stands rather than being converted to
Boolean first. So the conversion is essentially useless processing.
regards
Steve
--
Steve Holden +1 571 484 6266 +1 800 494 3119
Holden Web LLC http://www.holdenweb.com/
More information about the Python-list
mailing list