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


Groups > comp.lang.python > #15105

Re: __dict__ attribute for built-in types

From Peter Pearson <ppearson@nowhere.invalid>
Newsgroups comp.lang.python
Subject Re: __dict__ attribute for built-in types
Date 2011-10-28 15:52 +0000
Message-ID <9h01ehF8ogU1@mid.individual.net> (permalink)
References <4ea92dae$0$20639$426a74cc@news.free.fr> <Xns9F8B7A9C6BEE5duncanbooth@127.0.0.1> <4ea96437$0$24971$426a74cc@news.free.fr> <4ea9d8e6$0$29968$c3e8da3$5496439d@news.astraweb.com> <4ea9e0ba$0$2261$426a74cc@news.free.fr>

Show all headers | View raw


On Fri, 28 Oct 2011 00:52:40 +0200, candide <candide@free.invalid> wrote:
[snip]
>>>>> hasattr(42, '__dict__')
>> False
[snip]
>
> Let'have a try :
>
> >>> hasattr(43, '__dict__')
> False
> >>>
>
> so we have proved by induction that no integer instance has a 
> dictionnary attribute ;)

You left out an important step in this proof by induction.  Observe:

>>> n = 0
>>> hasattr(n, "__dict__")
False
>>> if hasattr(n, "__dict__") is False:
...   hasattr(n+1, "__dict__") is False
... 
True

There, now it's proven by induction.

-- 
To email me, substitute nowhere->spamcop, invalid->net.

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

__dict__ attribute for built-in types candide <candide@free.invalid> - 2011-10-27 12:08 +0200
  Re: __dict__ attribute for built-in types Arnaud Delobelle <arnodel@gmail.com> - 2011-10-27 11:36 +0100
  Re: __dict__ attribute for built-in types Duncan Booth <duncan.booth@invalid.invalid> - 2011-10-27 11:03 +0000
    Re: __dict__ attribute for built-in types Chris Angelico <rosuav@gmail.com> - 2011-10-28 00:25 +1100
      Re: __dict__ attribute for built-in types Duncan Booth <duncan.booth@invalid.invalid> - 2011-10-27 14:36 +0000
        Re: __dict__ attribute for built-in types Chris Angelico <rosuav@gmail.com> - 2011-10-28 09:39 +1100
    Re: __dict__ attribute for built-in types candide <candide@free.invalid> - 2011-10-27 16:01 +0200
      Re: __dict__ attribute for built-in types Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-10-27 22:19 +0000
        Re: __dict__ attribute for built-in types candide <candide@free.invalid> - 2011-10-28 00:52 +0200
          Re: __dict__ attribute for built-in types Terry Reedy <tjreedy@udel.edu> - 2011-10-27 22:44 -0400
          Re: __dict__ attribute for built-in types alex23 <wuwei23@gmail.com> - 2011-10-27 19:48 -0700
          Re: __dict__ attribute for built-in types Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-10-28 08:01 +0000
            Re: __dict__ attribute for built-in types candide <candide@free.invalid> - 2011-10-28 12:03 +0200
            Re: __dict__ attribute for built-in types Christian Heimes <lists@cheimes.de> - 2011-10-28 13:51 +0200
          Re: __dict__ attribute for built-in types Peter Pearson <ppearson@nowhere.invalid> - 2011-10-28 15:52 +0000
      Re: __dict__ attribute for built-in types Hrvoje Niksic <hniksic@xemacs.org> - 2011-10-28 00:57 +0200
        Re: __dict__ attribute for built-in types candide <candide@free.invalid> - 2011-10-28 01:36 +0200
          Re: __dict__ attribute for built-in types MRAB <python@mrabarnett.plus.com> - 2011-10-28 01:02 +0100
            Re: __dict__ attribute for built-in types candide <candide@free.invalid> - 2011-10-28 04:46 +0200
              Re: __dict__ attribute for built-in types Patrick Maupin <pmaupin@gmail.com> - 2011-10-27 20:02 -0700
                Re: __dict__ attribute for built-in types candide <candide@free.invalid> - 2011-10-28 12:04 +0200
          Re: __dict__ attribute for built-in types Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-10-28 06:21 +0000
          Re: __dict__ attribute for built-in types Hrvoje Niksic <hniksic@xemacs.org> - 2011-10-28 11:08 +0200
            Re: __dict__ attribute for built-in types candide <candide@free.invalid> - 2011-10-28 12:23 +0200
  Re: __dict__ attribute for built-in types Nobody <nobody@nowhere.com> - 2011-10-28 06:49 +0100

csiph-web