are there some special about '\x1a' symbol

John Machin sjmachin at lexicon.net
Sat Jan 10 22:40:44 CET 2009


On Jan 11, 2:45 am, "sim.sim" <Maksim.Kasi... at gmail.com> wrote:
> Hi all!
>
> I had touch with some different python behavior: I was tried to write
> into a file a string with the '\x1a' symbol, and for FreeBSD system,
> it gives expected result:
>
> >>> open("test", "w").write('before\x1aafter')
> >>> open('test').read()
>
> 'before\x1aafter'
>
> but for my WinXP box, it gives some strange:
>
> >>> open("test", "w").write('before\x1aafter')
> >>> open('test').read()
>
> 'before'
>
> Here I can write all symbols, but not read.
> I've tested it with python 2.6, 2.5 and 2.2 and WinXP SP2.
>
> Why is it so and is it possible to fix it?

You've already got two good answers, but this might add a little more
explanation:

You will aware that in Windows Command Prompt, to exit the interactive
mode of Python (among others), you need to type Ctrl-Z ...

| C:\junk>python
| Python 2.5.2 (r252:60911, Feb 21 2008, 13:11:45) [MSC v.1310 32 bit
(Intel)] on
win32
| Type "help", "copyright", "credits" or "license" for more
information.
| >>> problem = '\x1a'
| >>> ord(problem)
| 26
| >>> # What is the 26th letter of the English/ASCII alphabet?
| ...
| >>> ^Z
|
| C:\junk>

HTH,
John



More information about the Python-list mailing list