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


Groups > comp.lang.python > #28112

Re: class object's attribute is also the instance's attribute?

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!194.109.133.84.MISMATCH!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.001
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'attributes': 0.07; '__init__': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'def': 0.10; 'aug': 0.13; "'my": 0.16; 'a(object):': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'subject:class': 0.16; 'subject:instance': 0.16; 'subject:object': 0.16; 'wrote:': 0.17; 'instance,': 0.17; 'thu,': 0.17; 'define': 0.20; 'this:': 0.23; 'header:In-Reply-To:1': 0.25; 'header:User- Agent:1': 0.26; 'charset:iso-8859-15': 0.26; 'header:X-Complaints- To:1': 0.28; 'skip:_ 10': 0.29; 'class': 0.29; 'to:addr:python- list': 0.33; 'subject:?': 0.35; 'received:org': 0.36; 'except': 0.36; 'subject:: ': 0.38; 'to:addr:python.org': 0.39; 'header:Received:5': 0.40; 'oscar': 0.84; 'do:': 0.91
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Oscar Benjamin <oscar.j.benjamin@gmail.com>
Subject Re: class object's attribute is also the instance's attribute?
Date Thu, 30 Aug 2012 13:52:43 +0100
References <3830e549-cb6d-4bcf-af45-f7c83ad2b65e@googlegroups.com> <e8b14404-2340-4743-b66b-e9afb701e676@googlegroups.com>
Content-Type text/plain; charset=ISO-8859-15; format=flowed
Content-Transfer-Encoding 8bit
X-Gmane-NNTP-Posting-Host cpc1-aztw8-0-0-cust1455.18-1.cable.virginmedia.com
In-Reply-To <e8b14404-2340-4743-b66b-e9afb701e676@googlegroups.com>
User-Agent Groundhog Newsreader for Android
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
Precedence list
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.3967.1346331176.4697.python-list@python.org> (permalink)
Lines 14
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1346331176 news.xs4all.nl 6852 [2001:888:2000:d::a6]:51092
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:28112

Show key headers only | View raw


On Thu, 30 Aug 2012 05:34:51 -0700 (PDT), Marco Nawijn 
<nawijn@gmail.com> wrote:
> If you want attributes to be local to the instance, you have to 
define them in the __init__ section of the class like this:

> class A(object):
>    def __init__(self):
>         d = 'my attribute'

Except that in this case you'd need to do:
         self.d = 'my attribute'

Oscar

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


Thread

class object's attribute is also the instance's attribute? 陈伟 <chenwei.address@gmail.com> - 2012-08-30 03:55 -0700
  Re: class object's attribute is also the instance's attribute? Dave Angel <d@davea.name> - 2012-08-30 07:53 -0400
    Re: class object's attribute is also the instance's attribute? 陈伟 <chenwei.address@gmail.com> - 2012-08-30 05:57 -0700
    Re: class object's attribute is also the instance's attribute? 陈伟 <chenwei.address@gmail.com> - 2012-08-30 05:57 -0700
  Re: class object's attribute is also the instance's attribute? Ulrich Eckhardt <ulrich.eckhardt@dominolaser.com> - 2012-08-30 13:22 +0200
  Re: class object's attribute is also the instance's attribute? Marco Nawijn <nawijn@gmail.com> - 2012-08-30 05:34 -0700
    Re: class object's attribute is also the instance's attribute? Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2012-08-30 13:52 +0100
    Re: class object's attribute is also the instance's attribute? Hans Mulder <hansmu@xs4all.nl> - 2012-08-30 15:25 +0200
      Re: class object's attribute is also the instance's attribute? Marco Nawijn <nawijn@gmail.com> - 2012-08-30 07:11 -0700
        Re: class object's attribute is also the instance's attribute? Dave Angel <d@davea.name> - 2012-08-30 10:30 -0400
          Re: class object's attribute is also the instance's attribute? Marco Nawijn <nawijn@gmail.com> - 2012-08-30 07:48 -0700
            Re: class object's attribute is also the instance's attribute? Dave Angel <d@davea.name> - 2012-08-30 11:18 -0400
          Re: class object's attribute is also the instance's attribute? Marco Nawijn <nawijn@gmail.com> - 2012-08-30 07:48 -0700
            Re: class object's attribute is also the instance's attribute? Hans Mulder <hansmu@xs4all.nl> - 2012-08-30 17:20 +0200
              Re: class object's attribute is also the instance's attribute? Ben Finney <ben+python@benfinney.id.au> - 2012-08-31 09:58 +1000

csiph-web