On May 11, 10:47 am, Terry Reedy tjre...@udel.edu wrote:
anuraguni...@yahoo.com 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
Steven D'Aprano wrote:
On Fri, 08 May 2009 14:22:32 -0400, Terry Reedy wrote:
Scott David Daniels wrote:
rantIt 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
anuraguni...@yahoo.com 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
anuraguni...@yahoo.com anuraguni...@yahoo.com (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.
anuraguni...@yahoo.com 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 sense
anuraguni...@yahoo.com anuraguni...@yahoo.com 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 -*-
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
anuraguni...@yahoo.com 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
yes but my list sometimes have list of lists
On May 10, 2:59 pm, Diez B. Roggisch de...@nospam.web.de wrote:
anuraguni...@yahoo.com 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
anuraguni...@yahoo.com 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
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
anuraguni...@yahoo.com anuraguni...@yahoo.com (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
--
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, anuraguni...@yahoo.com wrote:
also not sure why (python 2.5)
print a # works
print unicode(a) # works
print [a] # works
print unicode([a]) # doesn't works
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
ru...@yahoo.com wrote:
On May 9, 10:08 am, Steven D'Aprano st...@remove-this-
cybersource.com.au wrote:
On Sat, 09 May 2009 08:37:59 -0700, anuraguni...@yahoo.com 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
anuraguni...@yahoo.com wrote in message
news:994147fb-cdf3-4c55-8dc5-62d769b12...@u9g2000pre.googlegroups.com...
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):
Mark Tolonen metolone+gm...@gmail.com (MT) wrote:
MT anuraguni...@yahoo.com wrote in message
MT news:994147fb-cdf3-4c55-8dc5-62d769b12...@u9g2000pre.googlegroups.com...
Sorry being unclear again, hmm I am becoming an expert in it.
I pasted that code as continuation of my old code at start
Piet van Oostrum p...@cs.uu.nl wrote in message
news:m263gagjjl@cs.uu.nl...
Mark Tolonen metolone+gm...@gmail.com (MT) wrote:
MT anuraguni...@yahoo.com wrote in message
MT
news:994147fb-cdf3-4c55-8dc5-62d769b12...@u9g2000pre.googlegroups.com...
Sorry being unclear again, hmm I am
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
On Sat, 09 May 2009 08:37:59 -0700, anuraguni...@yahoo.com 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__(self):
On May 9, 10:08 am, Steven D'Aprano st...@remove-this-
cybersource.com.au wrote:
On Sat, 09 May 2009 08:37:59 -0700, anuraguni...@yahoo.com 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):
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
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, anuraguni...@yahoo.com anuraguni...@yahoo.com
wrote:
First of all thanks everybody for putting time with my confusing post
and I apologize for not being
#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 UnicodeEncodeError,e:
print e
try:
anuraguni...@yahoo.com 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
Scott David Daniels wrote:
rantIt 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,
On Fri, 2009-05-08 at 07:53 -0700, anuraguni...@yahoo.com 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 __str__ and
J. Cliff Dyer j...@sdf.lonestar.org (JCD) a écrit:
JCD On Fri, 2009-05-08 at 07:53 -0700, anuraguni...@yahoo.com 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__ =
On Fri, 08 May 2009 14:22:32 -0400, Terry Reedy wrote:
Scott David Daniels wrote:
rantIt 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
29 matches
Mail list logo