Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #28119
| Date | 2012-08-30 09:23 -0400 |
|---|---|
| From | Dave Angel <d@davea.name> |
| Subject | Re: Beginners question |
| References | <k1nk8s$3l4$1@speranza.aioe.org> <mailman.3964.1346328894.4697.python-list@python.org> <k1nnj1$cal$1@speranza.aioe.org> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.3970.1346333002.4697.python-list@python.org> (permalink) |
On 08/30/2012 08:50 AM, boltar2003@boltar.world wrote: > On Thu, 30 Aug 2012 13:14:57 +0100 > MRAB <python@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
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Beginners question boltar2003@boltar.world - 2012-08-30 11:54 +0000
Re: Beginners question MRAB <python@mrabarnett.plus.com> - 2012-08-30 13:14 +0100
Re: Beginners question Roy Smith <roy@panix.com> - 2012-08-30 08:23 -0400
Re: Beginners question boltar2003@boltar.world - 2012-08-30 12:50 +0000
Re: Beginners question Chris Angelico <rosuav@gmail.com> - 2012-08-30 23:06 +1000
Re: Beginners question boltar2003@boltar.world - 2012-08-30 13:16 +0000
Re: Beginners question Dave Angel <d@davea.name> - 2012-08-30 09:23 -0400
Re: Beginners question Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2012-08-30 14:30 +0100
Re: Beginners question Terry Reedy <tjreedy@udel.edu> - 2012-08-30 14:22 -0400
Re: Beginners question Dave Angel <d@davea.name> - 2012-08-30 08:25 -0400
Re: Beginners question boltar2003@boltar.world - 2012-08-30 12:53 +0000
Re: Beginners question Chris Angelico <rosuav@gmail.com> - 2012-08-30 22:32 +1000
Re: Beginners question Ulrich Eckhardt <ulrich.eckhardt@dominolaser.com> - 2012-08-30 14:49 +0200
Re: Beginners question Ulrich Eckhardt <ulrich.eckhardt@dominolaser.com> - 2012-08-30 16:41 +0200
Re: Beginners question Hans Mulder <hansmu@xs4all.nl> - 2012-08-30 17:38 +0200
Re: Beginners question charvigroups@gmail.com - 2012-09-04 23:28 -0700
Re: Beginners question Mark Lawrence <breamoreboy@yahoo.co.uk> - 2012-09-05 09:03 +0100
Re: Beginners question Dave Angel <d@davea.name> - 2012-09-05 09:21 -0400
csiph-web