Re: binary literal

2009-07-23 Thread superpollo
Hendrik van Rooyen wrote: On Wednesday 22 July 2009 12:03:44 superpollo wrote: can i do something like the above, but using a *binary* number? (e.g. 00101101 instead of 45) ? 00101101 is not hex 45. hex 45 is 01000101 whoopsie daisie! chr(int('01000101',2)) 'E' much obliged. by

Re: binary literal

2009-07-23 Thread Hendrik van Rooyen
On Wednesday 22 July 2009 12:03:44 superpollo wrote: > can i do something like the above, but using a *binary* number? (e.g. > 00101101 instead of 45) ? 00101101 is not hex 45. hex 45 is 01000101 >>> chr(int('01000101',2)) 'E' >>> - Hendrik -- http://mail.python.org/mailman/listinfo/python-

Re: binary literal

2009-07-22 Thread Terry Reedy
superpollo wrote: hello clp. i can insert a hex value for a character literal in a string: >>> stuff = "\x45" >>> print stuff E >>> can i do something like the above, but using a *binary* number? (e.g. 00101101 instead of 45) ? Language Ref 2.4. Literals -- http://mail.python.org/mailma

Re: binary literal

2009-07-22 Thread Dave Angel
superpollo wrote: hello clp. i can insert a hex value for a character literal in a string: >>> stuff = "\x45" >>> print stuff E >>> can i do something like the above, but using a *binary* number? (e.g. 00101101 instead of 45) ? bye There's no way to get a binary value directly into a lit

Re: binary literal

2009-07-22 Thread Ulrich Eckhardt
superpollo wrote: > i can insert a hex value for a character literal in a string: > > >>> stuff = "\x45" > >>> print stuff > E > >>> > > can i do something like the above, but using a *binary* number? (e.g. > 00101101 instead of 45) ? There are binary number literals since 2.6 and there is th

Re: binary literal

2009-07-22 Thread Pablo Martí Gamboa
2009/7/22 superpollo > hello clp. > > i can insert a hex value for a character literal in a string: > > >>> stuff = "\x45" > >>> print stuff > E > >>> > > can i do something like the above, but using a *binary* number? (e.g. > 00101101 instead of 45) ? (Python 3) >>> bin(45) '0b101101' >>> in

binary literal

2009-07-22 Thread superpollo
hello clp. i can insert a hex value for a character literal in a string: >>> stuff = "\x45" >>> print stuff E >>> can i do something like the above, but using a *binary* number? (e.g. 00101101 instead of 45) ? bye -- http://mail.python.org/mailman/listinfo/python-list