Re: [Tutor] Bitwise operation

2011-02-28 Thread Steven D'Aprano
tee chwee liong wrote: my IDLE seems to be giving me some funny error. i'm using Python 2.5 and Win XP. pls advise. a=0b110010 SyntaxError: invalid syntax Base two literals were only added to Python in version 2.6. [steve@sylar ~]$ python2.6 ... >>> 0b111 7 In 2.5 and older, this is a

Re: [Tutor] Bitwise operation

2011-02-28 Thread tee chwee liong
> Binary (leading with '0b'): > >>> 0b1110 & 0b0110 > 6 > > Good luck, > > -Martin > my IDLE seems to be giving me some funny error. i'm using Python 2.5 and Win XP. pls advise. >>> a=0b110010 SyntaxError: invalid syntax >>> 0b1110 & 0b0110 SyntaxError: invalid syntax >>> 0b10 SyntaxErr

Re: [Tutor] Bitwise operation

2011-02-28 Thread David Hutto
On Mon, Feb 28, 2011 at 4:43 AM, Martin A. Brown wrote: > >  : i'm confused with & and AND. for eg: >  : >>> 1110 & 0110 >  : 64 >  : >>> 1110 and 0110 >  : 72 >  : >  : i'm expecting if 1110 and with 0110 will get 0110 or 6. >  : pls advise. > > Above, python thinks you are representing one numbe

Re: [Tutor] Bitwise operation

2011-02-28 Thread Martin A. Brown
: i'm confused with & and AND. for eg: : >>> 1110 & 0110 : 64 : >>> 1110 and 0110 : 72 : : i'm expecting if 1110 and with 0110 will get 0110 or 6. : pls advise. Above, python thinks you are representing one number in decimal notation and the other in octal. Decimal (no leading zeroe

[Tutor] Bitwise operation

2011-02-28 Thread tee chwee liong
hi, i'm confused with & and AND. for eg: >>> 1110 & 0110 64 >>> 1110 and 0110 72 i'm expecting if 1110 and with 0110 will get 0110 or 6. pls advise. thanks tcl ___ Tutor maillist - Tutor@python.org To