Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #28119

Re: Beginners question

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 <d@davea.name>
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 <d@davea.name>
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 <k1nk8s$3l4$1@speranza.aioe.org> <mailman.3964.1346328894.4697.python-list@python.org> <k1nnj1$cal$1@speranza.aioe.org>
In-Reply-To <k1nnj1$cal$1@speranza.aioe.org>
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 <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.3970.1346333002.4697.python-list@python.org> (permalink)
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

Show key headers only | View raw


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 | NextPrevious in thread | Next in thread | Find similar | Unroll thread


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