python: bug or feature?
Sean Blakey
sblakey at freei.com
Wed Aug 9 18:04:54 EDT 2000
On Wed, Aug 09, 2000 at 09:33:01PM +0000, Keith Murphy wrote:
> the first one works, but the second one always returns a 0.
>
> ( (e%4 == 0) & (self.current == e-1) )
>
> ( e%4 == 0 & self.current == e-1 )
>
> is there some reason the ordering in python can't accept the second
> one? thanks,
>
> -->keith
>
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
> --
> http://www.python.org/mailman/listinfo/python-list
Note that this works (returning 1 when e is 4 and self.current is 3, for
example)
( e%4 ==0 and self.current == e-1)
The prinary difference is that & is a binary bit-wise operator which
binds more tightly than ==, while "and" is a boolean operator.
According to the Python language reference "The expression x and y first
evaluates x; if x is false, its value is returned; otherwise, y is
evaluated and the resulting value is returned."
--
Sean Blakey, sblakey at freei.com
Software Developer, FreeInternet.com
(253)796-6500x1025
"No problem is so formidable that you can't walk away from it."
-- C. Schulz
More information about the Python-list
mailing list