By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
439,957 Members | 1,960 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 439,957 IT Pros & Developers. It's quick & easy.

force unicode strings

P: n/a
Hi,

is it possible to force all non ascii strings to be unicode strings
somehow?

Sometimes I forget that I need to write u'...' if the string contains
an umlaut. I get an exception in django later. But since the
exception does not show the string it is hard to find it.

Is it possible to loop over all strings the interpreter has parsed?

Pure ascii strings are OK.

Thomas

--
Thomas Gttler, http://www.thomas-guettler.de/ http://www.tbz-pariv.de/
E-Mail: guettli (*) thomas-guettler + de
Spam Catcher: ni**************@thomas-guettler.de

Aug 1 '07 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Thomas Guettler wrote:
is it possible to force all non ascii strings to be unicode strings
somehow?

Sometimes I forget that I need to write u'...' if the string contains
an umlaut. I get an exception in django later. But since the
exception does not show the string it is hard to find it.
I guess you can't afford to wait for Python 3, can you?

http://www.python.org/dev/peps/pep-3100/#atomic-types

Stefan
Aug 1 '07 #2

P: n/a
Stefan Behnel wrote:
>
I guess you can't afford to wait for Python 3, can you?

http://www.python.org/dev/peps/pep-3100/#atomic-types
No need to: just start python with the -U option:

Python 2.4.1 (#2, Oct 4 2006, 16:53:35)
[GCC 3.3.5 (Debian 1:3.3.5-8ubuntu2.1)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>""
u'\xe6\xf8\xe5'

It's just like Jython:

Jython 2.1 on java1.5.0_03 (JIT: null)
Type "copyright", "credits" or "license" for more information.
>>""
'\xE6\xF8\xE5'

That's a Unicode object, really. Various IronPython users have pointed
out similar things, too, but this kind of thing has been going on for
about ten years, I guess.

Paul

Aug 1 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.