On 12/13/2011 11:37 PM, Steven D'Aprano wrote:
x is a global? Poor design. But in any case, instead of an explicit
if...else block, the canonical way to convert an arbitrary object to True/
False is with bool:
def func_bool():
return bool(x)
But you don't need it. See below.
No no it
On Tue, 13 Dec 2011 16:24:05 +, Andrea Crotti wrote:
> I'm not sure for how long I had this bug, and I could not understand the
> problem.
>
> I had a function which would return a boolean
>
> def func_bool():
> if x:
> return True
> else: return False
x is a global? Poor
Andrea Crotti wrote:
I'm not sure for how long I had this bug, and I could not understand the
problem.
I had a function which would return a boolean
def func_bool():
if x:
return True
else: return False
Now somewhere else I had
if func_bool:
# do something
I could not qu
Andrea Crotti wrote:
> I'm not sure for how long I had this bug, and I could not understand
> the problem.
>
> I had a function which would return a boolean
>
> def func_bool():
> if x:
> return True
> else: return False
>
> Now somewhere else I had
>
> if func_bool:
>
On 2011-12-13, Andrea Crotti wrote:
> Now somewhere else I had
>
> if func_bool:
> # do something
>
> I could not quite understand why it was always true, until I finally
> noticed that the () were missing. Is there some tool to avoid these
> stupid mistakes? (pylint doesn't warn me on that)
I'm not sure for how long I had this bug, and I could not understand the
problem.
I had a function which would return a boolean
def func_bool():
if x:
return True
else: return False
Now somewhere else I had
if func_bool:
# do something
I could not quite understand why it