Re: unicode bit me

2009-05-11 Thread norseman
Steven D'Aprano wrote: On Fri, 08 May 2009 14:22:32 -0400, Terry Reedy wrote: Scott David Daniels wrote: It would be a bit easier if people would bother to mention their Python version, as we regularly get questions from people running 2.3, 2.4, 2.5, 2.6, 2.7a, 3.0, and 3.1b. They run comput

Re: unicode bit me

2009-05-11 Thread [email protected]
On May 11, 10:47 am, Terry Reedy wrote: > [email protected] wrote: > > so unicode(obj) calls __unicode__ on that object > > It will look for the existence of type(ob).__unicode__ ... > >  > and if it isn't there __repr__ is used > > According to the below, type(ob).__str__ is tried first. > >

Re: unicode bit me

2009-05-10 Thread Terry Reedy
[email protected] wrote: so unicode(obj) calls __unicode__ on that object It will look for the existence of type(ob).__unicode__ ... > and if it isn't there __repr__ is used According to the below, type(ob).__str__ is tried first. __repr__ of list by default return a str even if __rep

Re: unicode bit me

2009-05-10 Thread [email protected]
yes but my list sometimes have list of lists On May 10, 2:59 pm, "Diez B. Roggisch" wrote: > [email protected] schrieb: > > > ok that explains it, > > so > > unicode(obj) calls __unicode__ on that object and if it isn't there > > __repr__ is used > > __repr__ of list by default return a str

Re: unicode bit me

2009-05-10 Thread Diez B. Roggisch
[email protected] schrieb: ok that explains it, so unicode(obj) calls __unicode__ on that object and if it isn't there __repr__ is used __repr__ of list by default return a str even if __repr__ of element is unicode so my only solution looks like to use my own list class everywhere i use l

Re: unicode bit me

2009-05-10 Thread [email protected]
ok that explains it, so unicode(obj) calls __unicode__ on that object and if it isn't there __repr__ is used __repr__ of list by default return a str even if __repr__ of element is unicode so my only solution looks like to use my own list class everywhere i use list class mylist(list): def __

Re: unicode bit me

2009-05-10 Thread Nick Craig-Wood
[email protected] wrote: > First of all thanks everybody for putting time with my confusing post > and I apologize for not being clear after so many efforts. > > here is my last try (you are free to ignore my request for free > advice) > > # -*- coding: utf-8 -*- > > class A(object):

Re: unicode bit me

2009-05-09 Thread Peter Otten
[email protected] wrote: > First of all thanks everybody for putting time with my confusing post > and I apologize for not being clear after so many efforts. > > here is my last try (you are free to ignore my request for free > advice) Finally! This is the first of your posts that makes sen

Re: unicode bit me

2009-05-09 Thread Piet van Oostrum
> "[email protected]" (ac) wrote: >ac> and yes replace string by u'\N{COPYRIGHT SIGN}au' >ac> as mentioned earlier non-ascii char may not come correct posted here. That shouldn't be a problem for any decent new agent when there is a proper charset declaration in the headers. -- Piet va

Re: unicode bit me

2009-05-09 Thread Scott David Daniels
[email protected] wrote: class A(object): def __unicode__(self): return u"©au" def __repr__(self): return unicode(self).encode("utf-8") __str__ = __repr__ a = A() u1 = unicode(a) u2 = unicode([a]) now I am not using print so that doesn't matter stdout can print u

Re: unicode bit me

2009-05-09 Thread [email protected]
and yes replace string by u'\N{COPYRIGHT SIGN}au' as mentioned earlier non-ascii char may not come correct posted here. On May 10, 9:19 am, "[email protected]" wrote: > First of all thanks everybody for putting time with my confusing post > and I apologize for not being clear after so many e

Re: unicode bit me

2009-05-09 Thread [email protected]
First of all thanks everybody for putting time with my confusing post and I apologize for not being clear after so many efforts. here is my last try (you are free to ignore my request for free advice) # -*- coding: utf-8 -*- class A(object): def __unicode__(self): return u"©au"

Re: unicode bit me

2009-05-09 Thread rurpy
On May 9, 10:08 am, Steven D'Aprano wrote: > On Sat, 09 May 2009 08:37:59 -0700, [email protected] wrote: > > Sorry being unclear again, hmm I am becoming an expert in it. > > > I pasted that code as continuation of my old code at start i.e > > class A(object): > > def __unicode__(self)

Re: unicode bit me

2009-05-09 Thread Steven D'Aprano
On Sat, 09 May 2009 08:37:59 -0700, [email protected] wrote: > Sorry being unclear again, hmm I am becoming an expert in it. > > I pasted that code as continuation of my old code at start i.e > class A(object): > def __unicode__(self): > return u"©au" > > def __repr__(se

Re: unicode bit me

2009-05-09 Thread [email protected]
sorry for not being specfic and not given all info """ Python 2.5.2 (r252:60911, Jul 31 2008, 17:28:52) [GCC 4.2.3 (Ubuntu 4.2.3-2ubuntu7)] on linux2 'Linux-2.6.24-19-generic-i686-with-debian-lenny-sid' """ My question has not much to do with stdout because I am able to print unicode so print uni

Re: unicode bit me

2009-05-09 Thread Mark Tolonen
"Piet van Oostrum" wrote in message news:[email protected]... "Mark Tolonen" (MT) wrote: MT> wrote in message MT> news:[email protected]... Sorry being unclear again, hmm I am becoming an expert in it. I pasted that code as continuat

Re: unicode bit me

2009-05-09 Thread Piet van Oostrum
> "Mark Tolonen" (MT) wrote: >MT> wrote in message >MT> news:[email protected]... >>> Sorry being unclear again, hmm I am becoming an expert in it. >>> >>> I pasted that code as continuation of my old code at start >>> i.e >>> class A(object):

Re: unicode bit me

2009-05-09 Thread Mark Tolonen
wrote in message news:[email protected]... Sorry being unclear again, hmm I am becoming an expert in it. I pasted that code as continuation of my old code at start i.e class A(object): def __unicode__(self): return u"©au" def _

Re: unicode bit me

2009-05-09 Thread Scott David Daniels
[email protected] wrote: On May 9, 10:08 am, Steven D'Aprano wrote: On Sat, 09 May 2009 08:37:59 -0700, [email protected] wrote: Sorry being unclear again, hmm I am becoming an expert in it. I pasted that code as continuation of my old code at start i.e class A(object): def __unicode_

Re: unicode bit me

2009-05-09 Thread [email protected]
Sorry being unclear again, hmm I am becoming an expert in it. I pasted that code as continuation of my old code at start i.e class A(object): def __unicode__(self): return u"©au" def __repr__(self): return unicode(self).encode("utf-8") __str__ = __repr__ doesn't

Re: unicode bit me

2009-05-09 Thread J. Clifford Dyer
You're still not asking questions in a way that we can answer them. Define "Doesn't work." Define "a". On Sat, 2009-05-09 at 00:04 -0700, [email protected] wrote: > also not sure why (python 2.5) > print a # works > print unicode(a) # works > print [a] # works > print unicode([a]) # doesn'

Re: unicode bit me

2009-05-09 Thread Piet van Oostrum
> "[email protected]" (ac) a écrit: >ac> also not sure why (python 2.5) >ac> print a # works >ac> print unicode(a) # works >ac> print [a] # works >ac> print unicode([a]) # doesn't works Which code do you use now? And what does this print? import sys print sys.stdout.encoding -- Piet

Re: unicode bit me

2009-05-09 Thread [email protected]
also not sure why (python 2.5) print a # works print unicode(a) # works print [a] # works print unicode([a]) # doesn't works -- http://mail.python.org/mailman/listinfo/python-list

Re: unicode bit me

2009-05-08 Thread Steven D'Aprano
On Fri, 08 May 2009 14:22:32 -0400, Terry Reedy wrote: > Scott David Daniels wrote: > >> It would be a bit easier if people would bother to mention their >> Python version, as we regularly get questions from people running 2.3, >> 2.4, 2.5, 2.6, 2.7a, 3.0, and 3.1b. They run computers with diffe

Re: unicode bit me

2009-05-08 Thread Piet van Oostrum
> "J. Cliff Dyer" (JCD) a écrit: >JCD> On Fri, 2009-05-08 at 07:53 -0700, [email protected] wrote: >>> #how can I print a list of object which may return unicode >>> representation? >>> # -*- coding: utf-8 -*- >>> >>> class A(object): >>> >>> def __unicode__(self): >>> return u"©au" >>

Re: unicode bit me

2009-05-08 Thread J. Cliff Dyer
On Fri, 2009-05-08 at 07:53 -0700, [email protected] wrote: > #how can I print a list of object which may return unicode > representation? > # -*- coding: utf-8 -*- > > class A(object): > > def __unicode__(self): > return u"©au" > > __str__ = __repr__ = __unicode__ > Your

Re: unicode bit me

2009-05-08 Thread Terry Reedy
Scott David Daniels wrote: It would be a bit easier if people would bother to mention their Python version, as we regularly get questions from people running 2.3, 2.4, 2.5, 2.6, 2.7a, 3.0, and 3.1b. They run computers with differing operating systems and versions such as: Windows 2000, OS/X Leo

Re: unicode bit me

2009-05-08 Thread Scott David Daniels
[email protected] wrote: #how can I print a list of object which may return unicode representation? # -*- coding: utf-8 -*- class A(object): def __unicode__(self): return u"©au" __str__ = __repr__ = __unicode__ a = A() try: print a # doesn't work? except UnicodeEncod