New submission from Dirkjan Ochtman <dirk...@ochtman.nl>: 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... ---------- components: Library (Lib) messages: 103816 nosy: djc severity: normal status: open title: asyncore.dispatcher.__repr__() is weird versions: Python 2.6 _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue8483> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com