Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!newsfeed.datemas.de!feeder.erje.net!eu.feeder.erje.net!xlned.com!feeder3.xlned.com!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!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.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'attribute': 0.07; 'class,': 0.07; 'method.': 0.07; 'variables': 0.07; 'attributes': 0.09; 'method,': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'sub': 0.09; 'uses.': 0.09; 'python': 0.11; 'attribute.': 0.16; 'attributes,': 0.16; 'attributes.': 0.16; 'mean,': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'subject:class': 0.16; 'usable': 0.16; 'variables,': 0.16; 'wrote:': 0.18; 'variable': 0.18; 'first.': 0.19; 'normally': 0.19; 'written': 0.21; 'separate': 0.22; 'header:User-Agent:1': 0.23; 'visible': 0.24; 'regardless': 0.24; 'class.': 0.26; 'defined': 0.27; 'gets': 0.27; 'header:X -Complaints-To:1': 0.27; "doesn't": 0.30; 'code': 0.31; 'location,': 0.31; 'occurs': 0.31; 'subject:skip:i 10': 0.31; 'class': 0.32; 'lists': 0.32; 'quite': 0.32; 'but': 0.35; 'there': 0.35; 'charset:us-ascii': 0.36; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'either': 0.39; 'received:org': 0.40; 'called': 0.40; 'read': 0.60; "you're": 0.61; 'email addr:gmail.com': 0.63; 'such': 0.63; 'happen': 0.63; 'within': 0.65; 'between': 0.67; 'behavior': 0.77; 'different.': 0.84; 'studying': 0.84; 'hand,': 0.93 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Dave Angel Subject: Re: class implementation Date: Mon, 30 Sep 2013 19:34:08 +0000 (UTC) References: <6e338858-b9e6-4745-9959-35d7c0c7724e@googlegroups.com> <02724244-c924-4cf0-9656-71ade6e435c2@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: 174.32.174.35 User-Agent: XPN/1.2.6 (Street Spirit ; Linux) X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 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: 28 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1380569672 news.xs4all.nl 15925 [2001:888:2000:d::a6]:35956 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:55106 On 30/9/2013 08:41, markotaht@gmail.com wrote: > under variables, i mean, the int's and lists and strings and floats that the parent class uses. IF in parent class there is variable called location, then can i use the same variable in my sub class. Python doesn't actually have variables, but the things it documents as variables are local names within a method. Those are not visible outside of the method, regardless of whether you're in a class or a subclass. But perhaps you mean attributes. There are both class attributes and instance attributes, and the behavior is quite different. Roughly speaking a class attribute occurs only once per class, and all code can read its value with either Class.my_attrib or instance.my_attrib. It can be written with Class.my_attrib. On the other hand, instance attributes are usable by instance.my_attrib, regardless of whether the instance is a base class or a child class. Each instance of the class gets a separate copy of such an attribute. They are normally defined in the __init__() method. If you don't happen to know the difference between a class an an instance of that class, then all the above will look like gibberish, and you need to do some studying first. -- DaveA