473,725 Members | 2,220 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

how to print unicode structures?

Imagine you have some list that looks like
('unicode', 'not-acii', 'russian') and contains characters not from
acsii. or list of dicts, or dict of dicts.

how can I print it? not on by one, with "for" - but with just a simple
print? My debugging would be MUCH simpler.

Now when I try print or pprint that variable I get a page full of
'\xe4\xeb\xa2\x a0\xe6\xe3\xaa\ xe6\xe3\xaa' and so on.

I use Python 2.4, Fedora Linux, UTF-8 locale
Jul 18 '05 #1
2 2242
Timothy Babytch wrote:
Imagine you have some list that looks like
('unicode', 'not-acii', 'russian') and contains characters not from
acsii. or list of dicts, or dict of dicts.

how can I print it? not on by one, with "for" - but with just a simple
print? My debugging would be MUCH simpler.
I think the best (in terms of time) way to do it is to copy pprint.py
to upprint.py and hack it.

Now when I try print or pprint that variable I get a page full of
'\xe4\xeb\xa2\x a0\xe6\xe3\xaa\ xe6\xe3\xaa' and so on.


It looks like bytes, you should get rid of them as soon as possible. If you're not looking for speed hacks, as a rule of thumb you
should convert bytes to unicode characters as soon as possible. When I try to print Russian characters I get unicode escapes (\u)
not byte escapes (\x) like you:
print unicode([u''])

[u'\u0430\u0431\ u0432']

Serge.
Jul 18 '05 #2
Serge Orlov wrote:
print unicode([u''])

[u'\u0430\u0431\ u0432']

Oops, Outlook Express has screwed the encoding, one more evidence that printing unicode is hard :)
I hope this time, the message will be with real Russian characters instead of Latin ones.

Serge.
Jul 18 '05 #3

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

Similar topics

4
4298
by: Joerg Lehmann | last post by:
I am using Python 2.2.3 (Fedora Core 1). The problem is, that strings containing umlauts do not work as I would expect. Here is my example: >>> a = '' >>> b = '123' >>> print "%-5s %-5s\n%-5s %-5s" % (a,a,b,b) 123 123 I would expect, that the displayed width of a or b is the same: 5 characters.
4
2222
by: Ricardo Bugalho | last post by:
Hello, I'm using Python 2.3.4 and I noticed that, when stdout is a terminal, the 'print' statement converts Unicode strings into the encoding defined by the locales instead of the one returned by sys.getdefaultencoding(). However, I can't find any references to it. Anyone knows where it's descrbed? Example: !/usr/bin/env python
9
2323
by: Franois Pinard | last post by:
Hi, people. I hope someone would like to enlighten me. For any application handling Unicode internally, I'm usually careful at properly converting those Unicode strings into 8-bit strings before writing them out. However, this morning, I mistakenly forgot to do so before using one Unicode string (containing a non-ASCII character) as an argument to the `print' statement, and I did _not_ get an error. This is rather surprising to me. ...
5
2271
by: Tristan Miller | last post by:
Greetings. I have an XML file listing various information about text glyphs (Unicode value, HTML entity name, SGML entity name, etc.). All glyphs have a Unicode value, but not all of them have HTML or SGML entity names. I want to print out a list of these glyphs, using the HTML entity name if it is available; otherwise the Unicode value should be printed. The trouble is that I don't know how I can print only one or the other.
5
2553
by: Sonu | last post by:
Hello everyone and thanks in advance. I have a multilingual application which has been built in MFC VC++ 6.0 (non-Unicode). It support English German Hungarian so far, which has been fine. But now I need it to work on Russian computers and I realized that the application should be converted to Unicode to work in Russian. I am totally new to .NET so I'm not sure of this, but I read somewhere that if converted my apllication to .NET...
12
2445
by: Peter Lin | last post by:
Hey, I am just wondering if anyone has got any idea of setting up a new class so that you could just print like the old ways with the printer class, since I am writing a program that really requires simple black and white text printing, but there is alot to print and it's needed at various places, which is why I find that the new printing style with the printdocument a bit too clumsy. Any help would be appreciated.
5
1752
by: Norman Diamond | last post by:
Here are two complete lines of output from Visual Studio 2005: 1>$B%W%m%8%'%/%H=PNO$K(B Authenticode $B=pL>$7$F$$$^$9(B... 1>Successfully signed: c:\T The first line means roughly: Doing Authenticode signature to project output. The second line is harder to translate. The reason is that the second line says it successfully signed something that doesn't exist. I don't have a
3
3180
by: Terry Hancock | last post by:
I still run into my own ignorance a lot with unicode in Python. Is it possible to define some combination of __repr__, __str__, and/or __unicode__ so that the unicode() wrapper isn't necessary in this statement: <GLOSS: 青い, cl=None, {'wd': u'\u9752\u3044'}> (i.e. can I make it so that the object that print gets is already unicode, so that the label '青い' will print readably?)
8
12474
by: =?gb2312?B?yMvR1MLkyNXKx8zs0cSjrM37vKvM7NHEsru8+7z | last post by:
I lookup the utf-8 form of delta from the link. http://www.fileformat.info/info/unicode/char/0394/index.htm and then I want to print it in the python ( I work under windows) #!/usr/bin/python #coding=utf-8 print "\xce\x94"
0
9257
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9176
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8097
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectplanning, coding, testing, and deploymentwithout human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6702
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupr who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6011
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4519
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4784
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3221
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2635
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.