On 20 мар, 14:31, hellt <[EMAIL PROTECTED]> wrote: > i've faced with some strangeness while executing this sample: > > choice = raw_input("your choice: ") > print len(choice) > > when i run this sample in my eclipse console with CPython and print > Yes, i have this output > 4 #trailing \t is the fourth element > > but when i use command line method > python sample.py > i have the correct length = 3 > > i'm curious now, can anyone explain that?
just took a look into PyDEV-FAQ. "The eclipse console is not an exact copy of a shell... one of the changes is that when you press <ENTER> in a shell, it may give you a \r, \n or \r\n as an end-line char, depending on your platform. Python does not expect this -- from the docs it says that it will remove the last \n (checked in version 2.4), but, in some platforms that will leave a \r there. This means that the raw_input() should usually be used as raw_input().replace('\r', ''), and input() should be changed for: eval(raw_input().replace('\r', ''))." -- http://mail.python.org/mailman/listinfo/python-list