[Tutor] Misc question about scoping

Hugo Arts hugo.yoshi at gmail.com
Fri Jun 4 21:36:55 CEST 2010

On 4 jun 2010, at 21:02, ALAN GAULD <alan.gauld at btinternet.com> wrote:

Eek! no I'd just cast to a bool:

   flag = bool(someValue or another)

but the if/else form has the Pythonic virtue of explicitness.

Are you arguing that the if/else form is better than simply casting to bool
because it is more explicit? You could hardly name the cast implicit, it's
right there in your face.

If anything, I'd say the if/else is a more indirect way of expressing te
cast, even more so when you realize bool is called on the expression anyway
by the if statement, to determine its truthiness.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20100604/0212d2ba/attachment-0001.html>

More information about the Tutor mailing list