Escape chars in string

I

Ivo Woltring

Dear Pythoneers,

I have this app that I want to be able to present in more than 1 language.
To do this I use ConfigParser with an ini file.

My question:
when I 'get()' the message with ConfigParser the \t in the string is a
litteral and is not translated to a tab. Why is this so?
if I do tests with somthing like s = '&Quit\tAlt-Q' it does work.

What is the difference? and how can I get the desired behavior?

e.g.
[msg_quit]
uk = &Quit\tAlt-Q
nl = &Stoppen\tAlt-S


Hope y'all can help
Ivo.
 
J

Jeff Epler

Python 2.3 has a 'string-escape' codec. If you have a string like '\\t'
(a literal backslash followed by a t) and want to turn it into the
string '\t' (a tab character), you can use it for that purpose: 'a\tb'

Jeff

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)

iD8DBQFBj9qWJd01MZaTXX0RAnz4AJ9dNUmmjwam0XdvKZweP8jyOzfFHgCfTrq0
6ETGpZ6u3yHl9CmnpGs0fHM=
=OOfI
-----END PGP SIGNATURE-----
 
I

Ivo Woltring

Jeff Epler said:
Python 2.3 has a 'string-escape' codec. If you have a string like '\\t'
(a literal backslash followed by a t) and want to turn it into the
string '\t' (a tab character), you can use it for that purpose:

Jeff

Thanx!
exactly what i needed
Ivo.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,900
Latest member
Nell636132

Latest Threads

Top