How to print a unicode string?


I'd like to print out a unicode string. I'm running Python inside Emacs, which understands utf-8, so I want to force Python to send utf-8 to sys.stdout. From what I've googled, I think I need to set my locale. I ...
Posted On: Sunday 11th of November 2012 10:30:23 PM Total Views:  84
View Complete with Replies

RELATED TOPICS OF Python Programming PROGRAMMING LANGUAGE




Mysqldb printing sql and params no matter what I do

I had some code originally that printed the sql and params when I called the .execute method. I removed it but it still prints. I rebooted and renamed files and still it prints. I am totally stumped; I tried google but perhaps didn't use the right search; got a lot of hits but no clues. I'm using MySQLdb 1.2.2 and python 2.4.4 on XP here is a snipppet that shows problem. import MySQLdb from datetime import * DBSERVER='localhost' DBSCHEMA='mds81' sql = '''SELECT aid from assessments WHERE xmitdate between %s AND %s LIMIT 9''' class _record: def __init__(self, adict):self.__dict__=adict class CaptainQuery: def __init__(self, host, schema): self.Connection = MySQLdb.connect (host=host, db=schema) self.dictcursor = self.Connection.cursor(cursorclass=MySQLdb.cursors.DictCursor) print '----------before execute----------------' self.dictcursor.execute(sql, (20070201, 20070630) ) print '------------after execute-----------' records = self.dictcursor.fetchall() for r in records: print r Q = CaptainQuery(DBSERVER, DBSCHEMA ) ----------------- the output is below--------------------------------- ----------before execute---------------- SELECT aid from assessments WHERE xmitdate between %s AND %s LIMIT 9 (20070201, 20070630) ------------after execute----------- {'aid': 16711L} {'aid': 16712L} {'aid': 16713L} {'aid': 16715L} {'aid': 16845L} {'aid': 16849L} {'aid': 16850L} {'aid': 16851L} {'aid': 16852L} --------------------------------------------------------------------------- The information contained in this message may be privileged and / or confidential and protected from disclosure. If the reader of this message is not the intended recipient, you are hereby notified that any dissemination, distribution or copying of this communication is strictly prohibited. If you have received this communication in error, please notify the sender immediately by replying to this message and deleting the material from any computer. ---------------------------------------------------------------------------
VIEWS ON THIS POST

49

Posted on:

Wednesday 7th November 2012
View Replies!

replacement for string.printable

>From what I have read the string module is obsolete and should not be used but I am working on a project that parses printable files created in a DOS program and creates a web page for each file. I am using the string.printable constant to determine which characters should be kept; the files contain many print control codes. There seems to be nothing like this in the string methods. isalnum() seems the nearest but gives false for '+' '!' etc. I realise I could define a global string to cover this but wondered if there was another, better, way
VIEWS ON THIS POST

224

Posted on:

Wednesday 7th November 2012
View Replies!

How to print this character u'\u20ac' to DOS terminal

Who could explain the follow issue >>> print u'\t' \t >>> print u'' Traceback (most recent call last): File "", line 1, in UnicodeEncodeError: 'gbk' codec can't encode character u'\x80' in position 0: il legal multibyte sequence >>> or I just put the unicode number >>> print u'\u0394' \t >>> print u'\u20ac' Traceback (most recent call last): File "", line 1, in UnicodeEncodeError: 'gbk' codec can't encode character u'\u20ac' in position 0: illegal multibyte sequence >>> My terminal is cmd.exe under windows XP. what's the different between the two character what can I do if I want to print the u'\u20ac'
VIEWS ON THIS POST

35

Posted on:

Wednesday 7th November 2012
View Replies!

Re: printing list, is this a bug?

On May 25, 3:55 pm, William Chang wrote: > Is the different behavior between __repr__ and __str__ intentional > when it comes to printing lists Basically I want to print out a list > with elements of my own class, but when I overwrite __str__, __str__ > doesn't get called but if I overwrite __repr__, __repr__ will get > called. Is this a bug > ... As has been mentioned, this was a deliberate design decision. Partly to make things like str(['a', 'b, c']) less confusing.
VIEWS ON THIS POST

142

Posted on:

Wednesday 7th November 2012
View Replies!

pypy pycon 2006 sprint

Post-PyCon PyPy Sprint: February 27th - March 2nd 2006 ============================================================ The next PyPy sprint is scheduled to take place right after PyCon 2006 in Dallas, Texas, USA. We hope to see lots of newcomers at this sprint, so we'll give friendly introductions. Note that during the Pycon conference we are giving PyPy talks which serve well as preparation. Goals and topics of the sprint ------------------------------ While attendees of the sprint are of course welcome to work on what they wish, we offer these ideas: - Work on an 'rctypes' module aiming at letting us use a ctypes implementation of an extension module from the compiled pypy-c. - Writing ctypes implementations of modules to be used by the above tool. - Experimenting with different garbage collection strategies. - Implementing Python 2.5 features in PyPy - Implementation of constraints solvers and integration of dataflow variables to PyPy. - Implement new features and improve the 'py' lib and py.test which are heavily used by PyPy (doctests/test selection/...). - Generally experiment with PyPy -- for example, play with transparent distribution of objects or coroutines and stackless features at application level. - Have fun! Location -------- The sprint will be held wherever the PyCon sprints end up being held, which is to say somewhere within the Dallas/Addison Marriott Quorum hotel. For more information see the PyCon 06 sprint pages: - http://us.pycon.org/TX2006/Sprinting - http://wiki.python.org/moin/PyCon2006/Sprints Exact times ----------- The PyPy sprint will from from Monday February 27th until Thursday March 2nd 2006. Hours will be from 10:00 until people have had enough. Registration, etc. ------------------ If you know before the conference that you definitely want to attend our sprint, please subscribe to the `PyPy sprint mailing list`_, introduce yourself and post a note that you want to come. Feel free to ask any questions or make suggestions there! There is a separate `PyCon 06 people`_ page tracking who is already planning to come. If you have commit rights on codespeak then you can modify yourself a checkout of http://codespeak.net/svn/pypy/extrad...n06/people.txt ... _`PyPy sprint mailing list`: http://codespeak.net/mailman/listinfo/pypy-sprint ... _`PyCon 06 people`: http://codespeak.net/pypy/extradoc/s...n06/people.txt
VIEWS ON THIS POST

84

Posted on:

Wednesday 7th November 2012
View Replies!

Call for Participation: PyCon DC 2004 Sprints

Call for Participation PyCon DC 2004 Sprints March 20-23, 2004 http://www.python.org/cgi-bin/moinmoin/SprintPlan2004 The Python Software Foundation is sponsoring four days of sprints before PyCon -- Saturday through Tuesday. We invite developers to attend the sprints. We will provide space and network connectivity for developers who want to work on open source projects. A sprint is a two or three day focused development session, in which developers pair in a room and focus on building a particular subsystem. A sprint is organized with a coach leading the session. The coach sets the agenda, tracks activities, and keeps the development moving. The developers work in pairs using XP's pair programming approach. We have several sprints already planned, including - Docutils and reStructuredText - Plone - Twisted topics - Zope 2 and Zope 3 - Python core development If you are interested in participating in a sprint, please send mail to the appropriate sprint coach or to me. Developers of all experience levels are welcome. We are also looking for coaches for other sprints topics; if you have an idea, post it in the Wiki or send me an email. The PSF will waive PyCon registration fees for coaches of sprints with at least two attendees. Hope to see you there, Jeremy Hylton PyCon sprint chair
VIEWS ON THIS POST

28

Posted on:

Wednesday 7th November 2012
View Replies!

Vilnius/Post EuroPython PyPy Sprint 12-14th of July

The PyPy team is sprinting at EuroPython again and we invite you to participate in our 3 day long sprint at the conference hotel - Reval Hotel Lietuva. If you plan to attend the sprint we recommend you to listen to the PyPy technical talks (`EuroPython schedule`_) during the conference since it will give you a good overview of the status of development. On the morning of the first sprint day (12th) we will also have a tutorial session for those new to PyPy development. As 3 days is relatively short for a PyPy sprint we suggest to travel back home on the 15th if possible (but it is ok to attend less than 3 days too). ------------------------------ Goals and topics of the sprint ------------------------------ There are many possible and interesting sprint topics to work on - here we list some possible task areas: * completing the missing python 2.5 features and support * write or port more extension modules (e.g. zlib is missing) * identify slow areas of PyPy through benchmarking and work on improvements, possibly moving app-level parts of the Python interpreter to interp-level if useful. * there are some parts of PyPy in need of refactoring, we may spend some time on those, for example: - rctypes and the extension compiler need some rethinking - support for LLVM 2.0 for the llvm backend - ... * some JIT improvement work * port the stackless transform to ootypesystem * other interesting stuff that you would like to work on ...;-) ------------ Registration ------------ If you'd like to come, please subscribe to the `pypy-sprint mailing list`_ and drop a note about your interests and post any questions. More organisational information will be sent to that list. Please register by adding yourself on the following list (via svn): http://codespeak.net/svn/pypy/extrad...007/people.txt or on the pypy-sprint mailing list if you do not yet have check-in rights: http://codespeak.net/mailman/listinfo/pypy-sprint --------------------------------------- Preparation (if you feel it is needed): --------------------------------------- * read the `getting-started`_ pages on http://codespeak.net/pypy * for inspiration, overview and technical status you are welcome to read `the technical reports available and other relevant documentation`_ * please direct any technical and/or development oriented questions to pypy-dev at codespeak.net and any sprint organizing/logistical questions to pypy-sprint at codespeak.net * if you need information about the conference, potential hotels, directions etc we recommend to look at http://www.europython.org. We are looking forward to meet you at the Vilnius Post EuroPython PyPy sprint! The PyPy team ... See also .. ... _getting-started: http://codespeak.net/pypy/dist/pypy/...g-started.html ... _`pypy-sprint mailing list`: http://codespeak.net/mailman/listinfo/pypy-sprint ... _`the technical reports available and other relevant documentation`: http://codespeak.net/pypy/dist/pypy/doc/index.html ... _`EuroPython schedule`: http://europython.org/timetable
VIEWS ON THIS POST

31

Posted on:

Saturday 10th November 2012
View Replies!

Post-EuroPython sprint (6-9th July)

Geneva/CERN Post-EuroPython PyPy sprint 6-9th July ==================================================== The next PyPy sprint will be held at CERN/Geneva right after the EuroPython conference. We specifically invite newcomers and people interested to get to know and get into PyPy development. We are going ...
VIEWS ON THIS POST

49

Posted on:

Saturday 10th November 2012
View Replies!

PyPy Tokyo sprint 23/4 - 29/4

Tokyo PyPy Sprint: 23rd - 29th April 2006 ============================================================ The next PyPy sprint is scheduled to take place 23rd- 29th April 2006 (Sunday-Saturday) in Akihabara, Tokyo, Japan. We will together with FSIJ (Free Software Initiative of Japan) aim to promote ...
VIEWS ON THIS POST

80

Posted on:

Saturday 10th November 2012
View Replies!

Global Python Sprint Weekends: May 10th-11th and June 21st-22nd.

Following on from the success of previous sprint/bugfix weekends and sprinting efforts at PyCon 2008, I'd like to propose the next two Global Python Sprint Weekends take place on the following dates: * May 10th-11th (four days after 2.6a3 and ...
VIEWS ON THIS POST

54

Posted on:

Saturday 10th November 2012
View Replies!

pprint module and newer standard types

When I try and use pprint on standard types I get varying 'quality of output'. Lists will wrap nicely to multiple lines as will dicts, but sets and defaultdicts give one long unreadable line. Is their a chance to ...
VIEWS ON THIS POST

61

Posted on:

Saturday 10th November 2012
View Replies!

PyCon 2005 Sprints

PyCon 2005 is just around the corner. PyCon is a great place to meet and collaborate with your colleagues. A great way to collaborate at PyCon is through sprints. A sprint is a multi-day session of intense development organized around ...
VIEWS ON THIS POST

49

Posted on:

Saturday 10th November 2012
View Replies!

Short confusing example with unicode, print, and __str__

I really don't understand the following behavior: >>> class C(object): .... def __init__(self, s): self.s = s .... def __str__(self): return self.s .... >>> cafe = unicode("Caf\xe9", "Latin-1") >>> c = C(cafe) >>> print "Print using c.s:", c.s Print using ...
VIEWS ON THIS POST

108

Posted on:

Saturday 10th November 2012
View Replies!

How avoid both a newline and a space between 2 print commands?

print "foo" print "bar" has a newline in between "foo" and "bar" print "foo", print "bar" has a space in between "foo" and "bar" How prevent ANYTHING from going in between "foo" and "bar" \t (Without defining a string variable.) ...
VIEWS ON THIS POST

108

Posted on:

Saturday 10th November 2012
View Replies!

pexpect - not printing more than 80 columns

, I'm trying to write a script which will check the progress of my MD-simulations on a cluster. So far I've been able to ssh to each node and retrieve the data I was looking for by sending the ...
VIEWS ON THIS POST

162

Posted on:

Saturday 10th November 2012
View Replies!

Anyone in the Houston / College Station / Austin area? Looking to dosome sprints / joint projects.

, I'm in Houston/College Station/Austin quite often and I'm looking for other coders to do some joint projects with, share experiences, or do some sprints. Let me know if you're interested.
VIEWS ON THIS POST

172

Posted on:

Saturday 10th November 2012
View Replies!

Re: print "%s"

On 18Aug2008 11:58, Beema Shafreen wrote: | In my script i have to print a series of string , so | | print "%s\t%s\t%s\t%s\t%s\t%s\t" %("a","v","t","R","s","f") | | I need to know instead of typing so many %s can i ...
VIEWS ON THIS POST

69

Posted on:

Sunday 11th November 2012
View Replies!

Vilnius/Post EuroPython PyPy Sprint 10-12th of July

======================================================== Vilnius/Post EuroPython PyPy Sprint 10-12th of July ======================================================== The PyPy team is sprinting at EuroPython again and we invite you to participate in our 3 day long sprint at the conference hotel - Reval Hotel Lietuva. If you plan ...
VIEWS ON THIS POST

34

Posted on:

Sunday 11th November 2012
View Replies!

How to print a sorted list as a multi-column table

Hi all, I would like to ask about opinions about the best way to format sorted tables of items for interactive use. I have begun to add interactive help to Guppy/Heapy ( http://guppy-pe.sourceforge.net ) because it lacks the usual ways ...
VIEWS ON THIS POST

41

Posted on:

Sunday 11th November 2012
View Replies!

unicode newbie - printing mixed languages to the terminal

Hi list. I've never used unicode in a Python script before, but I need to now. I'm not sure where to start. I'm hoping that a kind soul can help me out here. My current (almost non-existant) knowledge of unicode: ...
VIEWS ON THIS POST

94

Posted on:

Sunday 11th November 2012
View Replies!