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: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.002 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'jeff': 0.04; '"""': 0.05; 'subject:Question': 0.07; 'python': 0.09; 'skip:b 70': 0.09; 'cc:addr:python-list': 0.10; 'def': 0.10; 'languages.': 0.15; 'a()': 0.16; 'b()': 0.16; 'googling': 0.16; 'member"': 0.16; 'subclasses.': 0.16; 'wrote:': 0.17; 'equivalent': 0.20; 'received:74.125.82.174': 0.23; 'cc:2**0': 0.23; 'sets': 0.23; 'cc:no real name:2**0': 0.24; 'cc:addr:python.org': 0.25; 'header :In-Reply-To:1': 0.25; '[1]': 0.27; 'message-id:@mail.gmail.com': 0.27; 'trouble': 0.28; 'skip:_ 10': 0.29; 'class': 0.29; 'code': 0.31; 'print': 0.32; 'received:74.125.82': 0.33; "can't": 0.34; 'received:google.com': 0.34; 'thanks': 0.34; 'skip:a 70': 0.35; 'received:74.125': 0.36; 'october': 0.37; 'subject:: ': 0.38; 'some': 0.38; 'skip:" 10': 0.40; 'header:Received:5': 0.40; 'help': 0.40; 'skip:a 30': 0.60; 'behavior': 0.64; 'here': 0.65; 'everybody': 0.69; 'oscar': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=P2ON42TrmkrVY4VdmLYGu9BHQY/YYBBIZp75dPf2nGo=; b=ZvNTEPf9nf6Nx/MN0ZKYMXe7+Ti/DnuDJ26JDxC/QZhyVt9iT7dJIVkAXap9Io3B7k 4vP3Qsos32kJswKViIHFSH1wFd2DRWBnyBKLQkuXA/8PP1Orpdn7AwhpzKsa8QsdCCrP VCf6qzK5j/J8YJAB+ydkY7cDhqgZ+dSAWcbfF73xRdMwPuKpw9qG4LtiqGU4z8vcMKmq qrmuDgsF9HfvsyXgWBFZ9IrbhA4MvDjExIye418ySF2iA1g+VVXcqo+JHfy3zrQKjSwk wIE1Tr2batzxZzWpBRkIzQn180w8/FiVHe7SPYm6K0NvRMf6U9NK/9vO/GKGCVSpX0qM SBXQ== MIME-Version: 1.0 In-Reply-To: References: Date: Thu, 18 Oct 2012 15:31:36 +0100 Subject: Re: Inheritance Question From: Oscar Benjamin To: Jeff Jeffries Content-Type: text/plain; charset=ISO-8859-1 Cc: python-list@python.org 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: 47 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1350570697 news.xs4all.nl 6938 [2001:888:2000:d::a6]:35831 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:31644 On 18 October 2012 15:10, Jeff Jeffries wrote: > Hello everybody > > When I set "AttributeChanges" in my example, it sets the same value for all > other subclasses. Can someone help me with what the name of this behavior is > (mutable class global?) ? .... I don't know any keywords... having trouble > googling it > > Thanks in advance, The code you attached is not so big that it can't just go in the email. Here it is: """ class ABMixin: AttributeChanges = [1] AttributeDontChangeImmutable = 1 def __init__(self): self.AttributeDontChange = [1] class A(object,ABMixin): def __init__(self): ABMixin.__init__(self) class B(object,ABMixin): def __init__(self): ABMixin.__init__(self) a = A() b = B() print a.AttributeChanges,a.AttributeDontChange,a.AttributeDontChangeImmutable print b.AttributeChanges,b.AttributeDontChange,b.AttributeDontChangeImmutable a.AttributeChanges[0] = 2 a.AttributeDontChange[0] = 2 a.AttributeDontChangeImmutable = 2 print a.AttributeChanges,a.AttributeDontChange,a.AttributeDontChangeImmutable print b.AttributeChanges,b.AttributeDontChange,b.AttributeDontChangeImmutable """ AttributeChanges is a "class attribute". This is the Python equivalent of what would be a "static class member" in some other languages. Oscar