On 08/30/2012 08:50 AM, boltar2003@boltar.world wrote: > On Thu, 30 Aug 2012 13:14:57 +0100 > MRAB <pyt...@mrabarnett.plus.com> wrote: > <snip> > If its a class , why is it when I create my own class I get a completely > different output with print and type? > >>>> class foo(object): > .. def __init__(self): > .. pass > .. >>>> f=foo() >>>> print f > <__main__.foo object at 0xb743956c>
You get that because you didn't provide a __str__() method in your class. As i said in my other message, posix.stat_result is providing that capability for your debugging convenience. There's no requirement to provide it, but that's why the difference. >>>> type(f) > <class '__main__.foo'> > > > I haven't discovered why sometimes the type output shows type instead of class. There are other ways of defining classes, however, and perhaps this is using one of them. Still, it is a class, and stat() is returning an instance of that class. -- DaveA -- http://mail.python.org/mailman/listinfo/python-list