On 12/07/2012 11:17 AM, gialloporpora wrote:
Risposta al messaggio di gialloporpora :

This is the code in my test.py:

Sorry, I have wrongly pasted the code:


class msgmarker(object):
    def __init__(self, msgid, msgstr, index, encoding="utf-8"):
        self._encoding =encoding
        self.set(msgid, msgstr)
        self._index = index

    def __repr__(self):
        return "<msgmarker object>"

    def __str__(self):
        return u'msgid: "%s"\nmsgstr: "%s"' %(self.msgid, self.msgstr)

    def isUntranslated(self):
        return self.msgid==self.msgstr

    def isFuzzy(self):
        return self.msgstr[0:2]=="=="

    def markFuzzy(self):
        self.msgstr = "==%s" %(self.msgstr)
    def set(self, msgid, msgstr):
if not(isinstance(msgid, unicode)): msgid = msgid.decode(self._encoding) if not(isinstance(msgstr, unicode)): msgstr = msgstr.decode(self._encoding)
        self.msgid = msgid
        self.msgstr = msgstr

    def setmsgstr(self, msgstr):
if not(isinstance(msgstr, unicode)): msgstr = msgstr.decode(self._encoding)
        self.msgstr = msgstr

    def getIndex(self):
        return self._index
    def getIndex(self):
        return self._index







what do you meant whe you say 'pretty print' ??.

is you just want to print a object in a nice format, you can use pprint

from pprint import pprint

nasty_dict = { 'hellou': bybye,
                        .....

Imagine that nasty_dict have many complex object. For pretty print in the python console you can do this:

pprint(nasty_dict).

Is you use ipython:

%page nasty_dict
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to