*blink* That's neat.
Quinn Dunkan
quinn at hedono.ugcs.caltech.edu
Tue May 30 04:11:12 EDT 2000
On Tue, 30 May 2000 07:19:02 GMT, Stephen Hansen
<stephen at cerebralmaelstrom.com> wrote:
>While writing a function, I curiousely typed this into the Interpreter:
>
>>>> if Case is not 0 or 1:
> ....
>
>etc..and it worked.. This was rather surprising to me :) Dunno why, but I
>expected I would have to write --> if Case is not 0 or Case is not 1:
Well, I'm not sure what you mean by "worked", but unless you mean "complicated
way to write 'if 1:'", it doesn't :) 'or' has lowest preceedence so:
if c is not 0 or 1:
if (c is not 0) or 1:
if (anything) or 1:
if 1:
But your expectation ('if Case is not 0 or Case is not 1:') is also a fancy
way of writing 'if 1:'. Stare at it a bit: 'Case' can't be 0 and 1 at the
same time, can it? I think what you meant was 'if Case is not 0 and Case is
not 1:'
It would also be better to use '==' since someone may want to *look* like a
number. And the fact that 'is' works for -1--99 is an implementation detail:
>>> a = 99
>>> a is 99
1
>>> a = 100
>>> a is 100
0
And the most pythonic of all may be:
if case not in 0, 1:
...
>Okay, there's really no point to this post.. I was just surprised and had to
>tell someone, and my roommate really, really, REALLY didn't care. Not that
>anyoen here does either, but you can't give me an agitated look :)
But we can write agitated followups :)
Your roommate is probably just thinking "how am I going to finish this
microprocessor design if this guy keeps babbling on about boolean operator
preceedence?"
More information about the Python-list
mailing list