Stéphane Ninin wrote:
> >>> from asyncore import dispatcher
> >>> d=dispatcher()
> >>> print d
> None
> >>> d
>
> >>> print type(d)
>
> >>> d.__class__
>
> >>> d is None
> False
> >>> ^Z
>
> why
> >>> print d
> prints None ?
it's a tricky one: the dispatcher class has a __repr__ method but no
Stéphane Ninin wrote:
> Hello,
>
> Probably a stupid question... but still:
>
>
from asyncore import dispatcher
d=dispatcher()
print d
>
> None
>
d
>
>
>
print type(d)
>
>
>
d.__class__
>
>
>
d is None
>
> False
>
^Z
>
>
> why
>
print d
>
Not 100% sure why print d gives None but if you need to print something
that represents the instance, use repr
>>> d.__str__
>>> str(d)
'None'
>>> repr(d)
''
>>> print repr(d)
Why isn't __str__ in dir?
>>> dir(d)
['__doc__', '__getattr__', '__init__', '__module__', '__repr__',
'_map', 'accept