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: 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 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> 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: 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: 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 On Thu, 30 Aug 2012 05:34:51 -0700 (PDT), Marco Nawijn 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