Luis Alberto Zarrabeitia Gomez wrote:
Quoting Jean-Michel Pichavant <jeanmic...@sequans.com>:
Emile van Sebille wrote:
On 7/16/2009 7:04 AM Unknown said...
On 2009-07-16, Emile van Sebille <em...@fenx.com> wrote:
daysInAdvance = int(inputVar) or 25
I don't get it. That doesn't work right when inputVar == "0".
Aah, but you didn't get to define right. :) For that particular
example 0 is not a valid response.
When I was talking about such error prone form of boolean operations, I
didn't expect to be right so quickly :p
What do you mean by being "right so quickly", and "error prone" in this context?
I would also ask "Unknown" why he believes that "int(intputVar) or 25" doesn't
work right when inputVar == "0". The only false value that int() may return is
zero, so the "or 25" clause is there only for that case. I can't see then how
you think that is an error.
I was saying that using boolean operators with object instead of boolean
values is error prone, cause no language behaves he same way, and all
behaviors are conventions difficult to figure out without diving deeply
into the documentation (or being explained as it happened to me).
I think the initialization trick is an error, because I don't want
foo(0) to set daysInAdvance to 25. I'll want it to set the attribute to
0, cause 0 is a valid integer. 0 is a valid integer content, None
wouldn't be a valid integer content.
JM
--
http://mail.python.org/mailman/listinfo/python-list