473,394 Members | 1,645 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Escape chars in string

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.


Jul 18 '05 #1
2 12797
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:
r"a\tb".decode("string-escape")

'a\tb'

Jeff

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

iD8DBQFBj9qWJd01MZaTXX0RAnz4AJ9dNUmmjwam0XdvKZweP8 jyOzfFHgCfTrq0
6ETGpZ6u3yHl9CmnpGs0fHM=
=OOfI
-----END PGP SIGNATURE-----

Jul 18 '05 #2
"Jeff Epler" <je****@unpythonic.net> wrote in message
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:
>>> r"a\tb".decode("string-escape")
'a\tb'

Jeff


Thanx!
exactly what i needed
Ivo.
Jul 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: TheKeith | last post by:
Hi, I'm just learning php now for the first time and I'm having a little trouble understanding something. In the following example: ...
4
by: swayze | last post by:
Hi, I'm sending some vars to php from javascript. These vars contain special chars (like "&" ,",")and also turkish characters. Therefore I'm using javascripts escape() function to be able to...
18
by: Steve Litvack | last post by:
Hello, I have built an XMLDocument object instance and I get the following string when I examine the InnerXml property: <?xml version=\"1.0\"?><ROOT><UserData UserID=\"2282\"><Tag1...
2
by: Pavils Jurjans | last post by:
Hello, I am looking fow C# equivalent of JavaScripts escape() and unescape() functions. I need to use C# function at the server side and then be able to use the opposite at the client side. ...
7
by: Luminal | last post by:
Greetings I'm having some problems on my C# application. I'm using an access database and I'm not able to do select queries with the ' character. My code is this: // some previous code like...
1
by: abcd | last post by:
Case 1 I have a variable called sConnectString whose value is "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=\\msxp102\shared\DBS\db3.mdb;User Id=;Password=;"; after this I call following...
6
by: Stijn Vanpoucke | last post by:
Hi, I've made a program with an access database. In my sql insert command I need to use escape characters to insert text strings but te problem is that I want to use escape chars in my text...
15
by: pkaeowic | last post by:
I am having a problem with the "escape" character \e. This code is in my Windows form KeyPress event. The compiler gives me "unrecognized escape sequence" even though this is documented in MSDN....
4
by: Jim Langston | last post by:
I want to build a string that contains the character 1, followed by ABC followed by the characters 255 255. One would think it would be simple: std::string Data( "\x01ABC\xFF\xFF", 6); but that...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.