Re: Weird list conversion

2015-12-13 Thread Chris Angelico
On Mon, Dec 14, 2015 at 7:31 AM, Erik wrote: > On 13/12/15 20:28, Erik wrote: >> >> When you call "print", then the list class's __repr__() method is called >> which in turn calls the contained objects' __repr__() methods in turn > > > I mean the __str__() method, not __repr__() in this case - how

Re: Weird list conversion

2015-12-13 Thread Larry Hudson via Python-list
On 12/13/2015 12:05 PM, KP wrote: On Sunday, 13 December 2015 11:57:57 UTC-8, Laura Creighton wrote: In a message of Sun, 13 Dec 2015 11:45:19 -0800, KP writes: Hi all, f = open("stairs.bin", "rb") data = list(f.read(16)) print data returns ['=', '\x04', '\x00', '\x05', '\

Re: Weird list conversion

2015-12-13 Thread Erik
On 13/12/15 20:28, Erik wrote: When you call "print", then the list class's __repr__() method is called which in turn calls the contained objects' __repr__() methods in turn I mean the __str__() method, not __repr__() in this case - however, the answer is otherwise the same. E. -- https://m

Re: Weird list conversion

2015-12-13 Thread Ian Kelly
On Sun, Dec 13, 2015 at 1:05 PM, KP wrote: > On Sunday, 13 December 2015 11:57:57 UTC-8, Laura Creighton wrote: >> In a message of Sun, 13 Dec 2015 11:45:19 -0800, KP writes: >> >Hi all, >> > >> > f = open("stairs.bin", "rb") >> > data = list(f.read(16)) >> > print data >> > >> >re

Re: Weird list conversion

2015-12-13 Thread Erik
On 13/12/15 20:05, KP wrote: On Sunday, 13 December 2015 11:57:57 UTC-8, Laura Creighton wrote: In a message of Sun, 13 Dec 2015 11:45:19 -0800, KP writes: Hi all, f = open("stairs.bin", "rb") data = list(f.read(16)) print data returns ['=', '\x04', '\x00', '\x05', '\x00', '\x01', '\x00', '

Re: Weird list conversion

2015-12-13 Thread KP
On Sunday, 13 December 2015 11:57:57 UTC-8, Laura Creighton wrote: > In a message of Sun, 13 Dec 2015 11:45:19 -0800, KP writes: > >Hi all, > > > > f = open("stairs.bin", "rb") > > data = list(f.read(16)) > > print data > > > >returns > > > >['=', '\x04', '\x00', '\x05', '\x00', '\

Re: Weird list conversion

2015-12-13 Thread Ian Kelly
On Sun, Dec 13, 2015 at 12:45 PM, wrote: > Hi all, > > f = open("stairs.bin", "rb") > data = list(f.read(16)) > print data > > returns > > ['=', '\x04', '\x00', '\x05', '\x00', '\x01', '\x00', '\x00', '\x00', '\x00', > '\x00', '\x00', '\x00', '\x00', '\x00', '\x00'] > > The fir

Re: Weird list conversion

2015-12-13 Thread Laura Creighton
In a message of Sun, 13 Dec 2015 11:45:19 -0800, high5stor...@gmail.com writes: >Hi all, > > f = open("stairs.bin", "rb") > data = list(f.read(16)) > print data > >returns > >['=', '\x04', '\x00', '\x05', '\x00', '\x01', '\x00', '\x00', '\x00', '\x00', >'\x00', '\x00', '\x00', '\x0

Weird list conversion

2015-12-13 Thread high5storage
Hi all, f = open("stairs.bin", "rb") data = list(f.read(16)) print data returns ['=', '\x04', '\x00', '\x05', '\x00', '\x01', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00'] The first byte of the file is 0x3D according to my hex editor, so why

Re: string to list conversion

2009-02-19 Thread Srinivas
John, Try the following code .. hope this helps and solves your problem . I have run in the interactive mode >>> s='' >>> a=[s,'12'] >>> print a ['', '12'] regards Srinivas -- http://mail.python.org/mailman/listinfo/python-list

Re: string to list conversion

2009-02-19 Thread MRAB
John Forse wrote: I need to convert an input string say '' to a list of the form ['' ,]. If I use list(stringname), I get ['x','x','x','x'] ; list.join() is an error; and str.join() won't use lists. I do need the comma after the string. Is there a simple solution? Have you tried [st

Re: string to list conversion

2009-02-19 Thread Steve Holden
John Forse wrote: > I need to convert an input string say '' to a list of the form > ['' ,]. If I use list(stringname), I get ['x','x','x','x'] ; > list.join() is an error; and str.join() won't use lists. I do need the > comma after the string. Is there a simple solution? Suppose your inp

string to list conversion

2009-02-19 Thread John Forse
I need to convert an input string say '' to a list of the form ['' ,]. If I use list(stringname), I get ['x','x','x','x'] ; list.join() is an error; and str.join() won't use lists. I do need the comma after the string. Is there a simple solution? Regards John -- http://mail.pytho

Re: Hexadecimal list conversion

2007-12-20 Thread Gabriel Genellina
En Thu, 20 Dec 2007 12:51:33 -0300, Peter Otten <[EMAIL PROTECTED]> escribió: > Mark T wrote: > >> "Gabriel Genellina" <[EMAIL PROTECTED]> wrote in message > >>> If you got that from a file, I bet you read it using the wrong >>> encoding. Try opening the file using codecs.open("filename", "rb",

Re: Hexadecimal list conversion

2007-12-20 Thread John Machin
On Dec 21, 2:51 am, Peter Otten <[EMAIL PROTECTED]> wrote: > Mark T wrote: > > "Gabriel Genellina" <[EMAIL PROTECTED]> wrote in message > >> If you got that from a file, I bet you read it using the wrong > >> encoding. Try opening the file using codecs.open("filename", "rb", > >> encoding="utf-16-b

Re: Hexadecimal list conversion

2007-12-20 Thread Peter Otten
Mark T wrote: > "Gabriel Genellina" <[EMAIL PROTECTED]> wrote in message >> If you got that from a file, I bet you read it using the wrong >> encoding. Try opening the file using codecs.open("filename", "rb", >> encoding="utf-16-be") instead of plain open. > There is an odd number of bytes in

Re: Hexadecimal list conversion

2007-12-20 Thread Mark T
"Gabriel Genellina" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > En Thu, 20 Dec 2007 09:30:14 -0300, Neil Webster <[EMAIL PROTECTED]> > escribi�: > >> I have a list which is a line from a file: >> ['\x003\x008\x001\x004\x007\x005\x00.\x005\x000\x002\x005\x009\x009\x00', >> '\x00

Re: Hexadecimal list conversion

2007-12-20 Thread Gabriel Genellina
En Thu, 20 Dec 2007 09:30:14 -0300, Neil Webster <[EMAIL PROTECTED]> escribi�: > I have a list which is a line from a file: > ['\x003\x008\x001\x004\x007\x005\x00.\x005\x000\x002\x005\x009\x009\x00', > '\x002\x001\x003\x006\x002\x002\x00.\x001\x007\x004\x002\x008\x002\x00'] > > This should be in

RE: Hexadecimal list conversion

2007-12-20 Thread Andreas Tawn
> Hi All. > > I have a list which is a line from a file: > ['\x003\x008\x001\x004\x007\x005\x00.\x005\x000\x002\x005\x009 > \x009\x00', > '\x002\x001\x003\x006\x002\x002\x00.\x001\x007\x004\x002\x008\ > x002\x00'] > > This should be in the format: > ['381475.502599', '213622.174282'] > > I've tr

Re: Hexadecimal list conversion

2007-12-20 Thread Paul Hankin
On Dec 20, 12:30 pm, Neil Webster <[EMAIL PROTECTED]> wrote: > Hi All. > > I have a list which is a line from a file: > ['\x003\x008\x001\x004\x007\x005\x00.\x005\x000\x002\x005\x009\x009\x00', > '\x002\x001\x003\x006\x002\x002\x00.\x001\x007\x004\x002\x008\x002\x00'] > > This should be in the form

Hexadecimal list conversion

2007-12-20 Thread Neil Webster
Hi All. I have a list which is a line from a file: ['\x003\x008\x001\x004\x007\x005\x00.\x005\x000\x002\x005\x009\x009\x00', '\x002\x001\x003\x006\x002\x002\x00.\x001\x007\x004\x002\x008\x002\x00'] This should be in the format: ['381475.502599', '213622.174282'] I've tried a few options using re

Re: List conversion

2006-03-30 Thread bruno at modulix
yawgmoth7 wrote: > Hello, I have a piece of code: > >command = raw_input("command> ") >words = string.split(command, ' ') >temparg = words >if len(words)<= 3: >temparg = words[4:] >else: >

List conversion

2006-03-29 Thread yawgmoth7
Hello, I have a piece of code: command = raw_input("command> ") words = string.split(command, ' ') temparg = words if len(words)<= 3: temparg = words[4:] else: tempar