unicode issue

2009-09-30 Thread gentlestone
Why don't work this code on Python 2.6? Or how can I do this job? _MAP = { # LATIN u'À': 'A', u'Á': 'A', u'Â': 'A', u'Ã': 'A', u'Ä': 'A', u'Å': 'A', u'Æ': 'AE', u'Ç':'C', u'È': 'E', u'É': 'E', u'Ê': 'E', u'Ë': 'E', u'Ì': 'I', u'Í': 'I', u'Î': 'I', u'Ï': 'I', u'Ð': 'D', u'Ñ': 'N', u

Re: unicode issue

2009-09-30 Thread gentlestone
On 30. Sep., 09:41 h., Andre Engels wrote: > On Wed, Sep 30, 2009 at 9:34 AM, gentlestone wrote: > > Why don't work this code on Python 2.6? Or how can I do this job? > > Please be more specific than "it doesn't work": > * What exactly are you doing > * W

Re: unicode issue

2009-09-30 Thread gentlestone
On 30. Sep., 10:35 h., Andre Engels wrote: > I get the feeling that the problem is with the Python interactive > mode. It does not have full unicode support, so u"Žabovitá zmiešaná > kaša" is changed to u'\x8eabovit\xe1 zmie\x9aan\xe1 ka\x9aa'. If you > call your code from another program, it migh

Re: unicode issue

2009-09-30 Thread gentlestone
On 30. Sep., 10:43 h., gentlestone wrote: > On 30. Sep., 10:35 h., Andre Engels wrote: > > > I get the feeling that the problem is with the Python interactive > > mode. It does not have full unicode support, so u"Žabovitá zmiešaná > > kaša" is changed to u

Re: unicode issue

2009-09-30 Thread gentlestone
On 30. Sep., 11:45 h., Dave Angel wrote: > gentlestone wrote: > > Why don't work this code on Python 2.6? Or how can I do this job? > > > _MAP = > >     # LATIN > >     u'À': 'A', u'Á': 'A', u'Â': 'A'

Re: unicode issue

2009-09-30 Thread gentlestone
>save in utf-8 the coding declaration also has to be utf-8 ok, I understand, but what's the problem? Unfortunately seems to be the Python interactive mode doesn't have unicode support. It recognize the latin-1 encoding only. So I have 2 options, how to write doctest: 1. Replace native charaters w

Re: unicode issue

2009-10-05 Thread gentlestone
Thx for useful advices. They seems to be very clever. Thx to dajngo users comunity, I've got a nice solution, how to avoid unicode problems in doctests: """ >>> Osoba(meno = "Ľudmila".decode('utf-8'), priezvisko = "Šafářová".decode('utf-8')) """ It is - do not use unicode string

Creating class instance from module and class name

2009-10-05 Thread gentlestone
Suppose I've saved the class name and (don't know how) I've also saved the Class's module (package path or I don't know what's the name for XYZ "from X.Y.Z import ...). How can I construct a new class according to saved informations? If I don't know what Class it could be, only I have the saved Cla

Re: Creating class instance from module and class name

2009-10-06 Thread gentlestone
On 6. Okt, 08:55 h., Steven D'Aprano wrote: > On Mon, 05 Oct 2009 23:32:27 -0700, gentlestone wrote: > > Suppose I've saved the class name and (don't know how) I've also saved > > the Class's module (package path or I don't know what's the n

AOP decorator?

2010-03-01 Thread gentlestone
Hi, suppose my source code looks like: import aspect_xy class Basic(object, aspect_xy.Basic): pass # basic attributes and methods ... and the source code of aspect_xy.py is: class Basic(obj

monkey patching with @classmethod

2010-03-03 Thread gentlestone
Hi, is there some well-known problems with class method monkey patching? I've got this error message: unbound method get_pocet_neocislovanych() must be called with Pozemok instance as first argument (got Subjekt instance instead) The method is declared as: @classmethod @monkeypatch(Dokument) def

Re: monkey patching with @classmethod

2010-03-03 Thread gentlestone
On 3. Mar., 12:57 h., gentlestone wrote: > Hi, is there some well-known problems with class method monkey > patching? > > I've got this error message: > > unbound method get_pocet_neocislovanych() must be called with Pozemok > instance as first argument (got Subjekt

Re: monkey patching with @classmethod

2010-03-03 Thread gentlestone
On 3. Mar., 13:09 h., Bruno Desthuilliers wrote: > gentlestone a écrit : > > > > > Hi, is there some well-known problems with class method monkey > > patching? > > > I've got this error message: > > > unbound method get_pocet_neocislovanych() mu

(a==b) ? 'Yes' : 'No'

2010-03-30 Thread gentlestone
Hi, how can I write the popular C/JAVA syntax in Python? Java example: return (a==b) ? 'Yes' : 'No' My first idea is: return ('No','Yes')[bool(a==b)] Is there a more elegant/common python expression for this? -- http://mail.python.org/mailman/listinfo/python-list

Usefull python tutorial

2009-08-26 Thread gentlestone
Can somebody give me an advise where I can found a really good online tutorial? All I found are useless. For example no tutorial I found explains this piece of code: someList = [element for element in otherList if element is not None] or this example: a = a or [] There are only stupid e

How can I format unicode strings?

2009-09-09 Thread gentlestone
return u"{}".format(self.name) this one doesn't work on unicode strings. I there a not old formatting style possibilty for unicode strings? Note: self.name can be unicode string! -- http://mail.python.org/mailman/listinfo/python-list

Re: How can I format unicode strings?

2009-09-09 Thread gentlestone
On 9. Sep., 12:31 h., Tim Northover wrote: > gentlestone writes: > >  return u"{}".format(self.name) > > > this one doesn't work on unicode strings. I there a not old formatting > > style possibilty for unicode strings? > > It looks like you're