Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!ecngs!feeder2.ecngs.de!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.009 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'output': 0.04; 'classes,': 0.05; 'debugging': 0.05; 'mrab': 0.05; 'class,': 0.07; 'subject:question': 0.08; 'cc:addr:python-list': 0.10; 'def': 0.10; 'aug': 0.13; 'foo(object):': 0.16; 'still,': 0.16; 'wrote:': 0.17; 'instance': 0.17; 'thu,': 0.17; 'cc:2**0': 0.23; 'class.': 0.23; "haven't": 0.23; 'cc:no real name:2**0': 0.24; 'pass': 0.25; 'cc:addr:python.org': 0.25; 'header:In-Reply-To:1': 0.25; 'header :User-Agent:1': 0.26; 'am,': 0.27; '+0100': 0.27; '>>>>': 0.29; 'skip:_ 10': 0.29; 'class': 0.29; 'print': 0.32; 'defining': 0.33; 'returning': 0.35; 'sometimes': 0.35; 'there': 0.35; 'but': 0.36; "didn't": 0.36; 'method': 0.36; 'why': 0.37; 'subject:: ': 0.38; 'shows': 0.38; 'instead': 0.39; 'received:192': 0.39; 'received:192.168': 0.40; 'your': 0.60; 'provide': 0.62; 'different': 0.63; 'header:Reply-To:1': 0.68; 'received:74.208': 0.71; 'reply-to:no real name:2**0': 0.72; 'discovered': 0.83; 'difference.': 0.84; 'received:74.208.4.194': 0.84; 'capability': 0.91; 'to:none': 0.93 Date: Thu, 30 Aug 2012 09:23:03 -0400 From: Dave Angel User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:14.0) Gecko/20120714 Thunderbird/14.0 MIME-Version: 1.0 CC: python-list@python.org Subject: Re: Beginners question References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Provags-ID: V02:K0:Uw5qvdwOrVnC7vRDDAQu8lD4Xm3b0bLb7YJYaWL3thS M7z5oW9VN1HO9mCSPISQuPpVv7QbBTS2YZRS8qiTcC6dnX2bZx +URCc1Cwgux6TaawmKMfD4eKYKpEVn8sHJdDi/zPX9MaVylCxa rPOygWH0vHLsdPIU3FI5frco0x7QjzV/tEE74bk/hx6gLwGgiD Jiiv2DuOvNBXTLN+pSw6Zs41wF5We/aHoxIjQBKuGnQrAoe6Xr Fa6PedXXOf/i50/sbu3CflWaqTsCVz1wksXK7ePIoZbhPcWcID 1+s0TD2JIRFrUrxIX0BmAZWcIMrXm4pMxYqciL+8uORuVpNJg= = X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list Reply-To: d@davea.name List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 35 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1346333002 news.xs4all.nl 6986 [2001:888:2000:d::a6]:45694 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:28119 On 08/30/2012 08:50 AM, boltar2003@boltar.world wrote: > On Thu, 30 Aug 2012 13:14:57 +0100 > MRAB wrote: > > 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) > > > > 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