are there some special about '\x1a' symbol

sim.sim Maksim.Kasimov at gmail.com
Mon Jan 12 14:45:33 CET 2009


On 10 янв, 23:40, John Machin <sjmac... at lexicon.net> wrote:
> 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

Hi John,

I agree - those two answers are really good. Thanks to Mel and Marc.
I'm sorry if my stupid question was annoyed you.

--
Maksim



More information about the Python-list mailing list