[Tutor] Misc question about scoping

Hugo Arts hugo.yoshi at gmail.com
Fri Jun 4 16:31:11 CEST 2010


On Fri, Jun 4, 2010 at 1:23 PM, Dave Angel <davea at ieee.org> wrote:
>
> I'd prefer the form:
>
>  flag = not not (someValue or another)
>

That's a construct you might commonly find in languages like C, but I
don't think it's very pythonic. If you want to convert your result to
a bool, be explicit about it:

flag = bool(some_value or another)

I'd agree that the if/else construct is redundant if you just want a
True/False result, but the double not is a kind of implicit type
conversion that is easily avoided.

Hugo


More information about the Tutor mailing list