asyncore question

snoe case.nelson at gmail.com
Wed Nov 23 12:37:45 EST 2005


Not 100% sure why print d gives None but if you need to print something
that represents the instance, use repr

>>> d.__str__
<method-wrapper object at 0x0098C450>
>>> str(d)
'None'
>>> repr(d)
'<asyncore.dispatcher at 0x8d5be8>'
>>> print repr(d)
<asyncore.dispatcher at 0x8d5be8>


Why isn't __str__ in dir?
>>> dir(d)
['__doc__', '__getattr__', '__init__', '__module__', '__repr__',
'_map', 'accept
', 'accepting', 'add_channel', 'addr', 'bind', 'close', 'closing',
'connect', 'c
onnected', 'create_socket', 'debug', 'del_channel', 'handle_accept',
'handle_clo
se', 'handle_connect', 'handle_error', 'handle_expt',
'handle_expt_event', 'hand
le_read', 'handle_read_event', 'handle_write', 'handle_write_event',
'listen', '
log', 'log_info', 'readable', 'recv', 'send', 'set_reuse_addr',
'set_socket', 's
ocket', 'writable']




More information about the Python-list mailing list