Re: interpretation of special characters in Python

2008-07-07 Thread TP
Peter Pearson wrote: > I don't understand exactly what you mean by "Sorry" I means: please forgive me for having said that it does not work with variables, because it is completely false. Thanks one more time Julien -- TP (Tribulations Parallèles) "Allez, Monsieur, allez, et la foi vous vien

Re: interpretation of special characters in Python

2008-07-07 Thread Peter Pearson
On Mon, 07 Jul 2008 10:05:56 +0200, TP <[EMAIL PROTECTED]> wrote: > TP wrote: > >> So, the python print command *can* interpret these 4-character as a single >> character. It would be odd if there were no possibility to do the same >> thing when the characters are (i) stored in a python variable >

Re: interpretation of special characters in Python

2008-07-07 Thread TP
Peter Otten wrote: esc = os.environ["esc"].decode("string-escape") esc > '\x1b' print "%s[30;44malles so schoen bunt hier%s[0m" % (esc, esc) > alles so schoen bunt hier Thanks a lot for your help. It works perfectly. Indeed, one can read in the documentation concerning encodings:

Re: interpretation of special characters in Python

2008-07-07 Thread Peter Otten
Peter Pearson wrote: > On Sun, 06 Jul 2008 23:42:26 +0200, TP <[EMAIL PROTECTED]> > wrote: >> >> $ python -c "print '\033[30;44m foo \033[0m'" > [writes an escape sequence to stdout] > >> $ echo -e $esc$ColorBlackOnDarkblue foo $esc$ColorReset > [also writes an escape sequence to stdout] > >> $

Re: interpretation of special characters in Python

2008-07-07 Thread TP
TP wrote: > So, the python print command *can* interpret these 4-character as a single > character. It would be odd if there were no possibility to do the same > thing when the characters are (i) stored in a python variable Sorry, it works when using variables. Try for example: col="[0;31m" esc=

Re: interpretation of special characters in Python

2008-07-07 Thread Ben Finney
TP <[EMAIL PROTECTED]> writes: > Peter Pearson wrote: > > > When you tell python "print '\033[30;44m foo \033[0m'", python > > interprets the "\033" as a single character. > > So, the python print command *can* interpret these 4-character as a > single character. Not "interpret", no. It's more

Re: interpretation of special characters in Python

2008-07-06 Thread TP
Peter Pearson wrote: Thanks for your answer. > When you run echo, it recognizes the 4-character "esc" as a > convention for representing a single character, and performs > the re-interpretation for you. When you tell python > "print '\033[30;44m foo \033[0m'", python interprets > the "\033" as a

Re: interpretation of special characters in Python

2008-07-06 Thread TP
Dennis Lee Bieber wrote: > Off-hand, I'd probably try first with: > > csi = "\033[" > > and then define your > > colorblackondarkblue = $csi"30;44m" Thanks for your answer. I have tried this slight modification, but it does not change anything on my terminal. -- TP (Tribulations Parallèles)

Re: interpretation of special characters in Python

2008-07-06 Thread Peter Pearson
On Sun, 06 Jul 2008 23:42:26 +0200, TP <[EMAIL PROTECTED]> wrote: > > $ python -c "print '\033[30;44m foo \033[0m'" [writes an escape sequence to stdout] > $ echo -e $esc$ColorBlackOnDarkblue foo $esc$ColorReset [also writes an escape sequence to stdout] > $ echo -n $esc$ColorBlackOnDarkblue foo

interpretation of special characters in Python

2008-07-06 Thread TP
Hi everybody, I am new to Python, I try to understand how Python treats special characters. For example, if I execute the following line in a shell console, I obtain a colored string: $ python -c "print '\033[30;44m foo \033[0m'" So, it works. Some time ago, I have made a lot of shell variables