Message103816
This is rather confusing:
Python 2.6.4 (r264:75706, Mar 8 2010, 08:41:55)
[GCC 4.3.4] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import socket, asyncore
>>> class T:
... pass
...
>>> t = T()
>>> print t
<__main__.T instance at 0x18237a0>
>>> print repr(t)
<__main__.T instance at 0x18237a0>
>>> class A(asyncore.dispatcher):
... pass
...
>>> a = A()
>>> print a
None
>>> print repr(a)
<__main__.A at 0x179c0e0>
>>> class B(asyncore.dispatcher):
... def __init__(self, *args):
... asyncore.dispatcher.__init__(self, *args)
...
>>> sock = socket.socket()
>>> b = B(sock)
>>> print b
<socket._socketobject object at 0x7fcef226e8a0>
>>> print repr(b)
<__main__.B at 0x179c0e0>
Here's dispatcher's __repr__:
def __repr__(self):
status = [self.__class__.__module__+"."+self.__class__.__name__]
if self.accepting and self.addr:
status.append('listening')
elif self.connected:
status.append('connected')
if self.addr is not None:
try:
status.append('%s:%d' % self.addr)
except TypeError:
status.append(repr(self.addr))
return '<%s at %#x>' % (' '.join(status), id(self))
Which doesn't seem excessively complex... |
|
Date |
User |
Action |
Args |
2010-04-21 10:55:25 | djc | set | recipients:
+ djc |
2010-04-21 10:55:25 | djc | set | messageid: <1271847325.07.0.737920517858.issue8483@psf.upfronthosting.co.za> |
2010-04-21 10:55:24 | djc | link | issue8483 messages |
2010-04-21 10:55:22 | djc | create | |
|