Path: csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder2.enfer-du-nord.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed6.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.006 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'attribute': 0.07; 'python': 0.08; 'referencing': 0.09; 'am,': 0.12; 'def': 0.13; '"z",': 0.16; '*always*': 0.16; 'a():': 0.16; 'c++.': 0.16; 'doing:': 0.16; 'subclassing': 0.16; 'cc:addr:python-list': 0.16; 'wrote:': 0.18; 'cheers,': 0.20; 'java': 0.21; 'cc:no real name:2**0': 0.21; 'header:In-Reply-To:1': 0.22; 'wrong?': 0.23; 'received:209.85.220': 0.25; 'cc:2**0': 0.26; 'message- id:@mail.gmail.com': 0.29; 'explicitly': 0.29; 'class': 0.29; 'problem': 0.29; 'cc:addr:python.org': 0.29; 'object.': 0.30; 'sun,': 0.30; 'chris': 0.30; 'creates': 0.31; 'instead.': 0.32; 'minor': 0.32; "isn't": 0.33; 'named': 0.33; 'skip:# 10': 0.34; 'thank': 0.35; 'problem.': 0.35; 'things': 0.35; 'but': 0.37; 'received:google.com': 0.37; 'skip:_ 10': 0.38; 'received:209.85': 0.38; 'doing': 0.38; 'should': 0.38; 'received:209': 0.39; 'point': 0.40; 'your': 0.61; 'cause': 0.67; '11,': 0.68; 'sender:addr:chris': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rebertia.com; s=google; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=h+6DSkpVrgwtutjYatLGI2PlLlZrQUEYg56n0bN+hJs=; b=JqsjAIcmeU1v0thsRmEsuD/jsD5NPH24DKFCCVxpsDAttKQny4OzNDtlWK7mk9pvEf QbQHiKnvUT12NGwHt+z2xCw8+RzYSyQS5Us+suIJUTihSY5acmEoy42YHuU1nWtVYiFi tXXAta07F0IuBgpl351ggdTdPMELy79XEfUwc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type :content-transfer-encoding:x-gm-message-state; bh=h+6DSkpVrgwtutjYatLGI2PlLlZrQUEYg56n0bN+hJs=; b=CIDPrP9NbD32N+lsXgKVu9DwSM6QGx5AOOdir6MMxy5rq2F/DqpOIEISQCU9pfSfM5 kjUs8/EXBeWp4c/PYwskwJYPpmFIsqZX+K2Kstc97XkBL5eyqDWzv6RMlFx/GVJ2dO+y sWK8XKJ8qxCq+2vbWX9Az/jwOWg7aMvAE2QvWrflrpZrThbIGWTYe9UM9Mtlek5KrmCP 5lGPkszq7/gJKcwQzEH7DbntXPUV2puZMAMd9UiaqoFl1Qk87HRI5DZg5bB5bIPkStLi KDq1YTLIpOKE/kNptuNtVgVZWVXcwbwCNSsADkYXtrqoTGVEWkLfySeqhHurbo8Q3IZZ iFIQ== MIME-Version: 1.0 Sender: chris@rebertia.com In-Reply-To: <2feb13ca-f83b-4843-995f-ee77e7505ecd@db5g2000vbb.googlegroups.com> References: <1c6db866-6fa3-4de5-96de-51d6720a1300@x17g2000yqj.googlegroups.com> <2feb13ca-f83b-4843-995f-ee77e7505ecd@db5g2000vbb.googlegroups.com> Date: Sun, 11 Mar 2012 03:38:27 -0700 X-Google-Sender-Auth: 6Q-_5H1Z8laNpGpBBf4MUR8p5WA Subject: Re: newb __init__ inheritance From: Chris Rebert To: hyperboogie Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Gm-Message-State: ALoCoQmzXZPPh25en6h9PxhBzE1h76GpT8+/XXyfD7TMwG2CAwnKWw1EB+wqkUwiEHTB77Usomzp Cc: python-list@python.org 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: 25 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1331462311 news.xs4all.nl 6902 [2001:888:2000:d::a6]:54715 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:21487 On Sun, Mar 11, 2012 at 3:18 AM, hyperboogie wrote: > thank you everyone... > Still things are not working as expected... what am I doing wrong? > # cat test.py > #!/usr/bin/python > > class A(): You should be subclassing `object`, but that's a minor point which isn't the cause of your problem. > =C2=A0 def __init__(self): > =C2=A0 =C2=A0 =C2=A0z=3D1 This creates a *local variable* named "z". You want an *attribute* named "z", so you should be doing: self.z =3D 1 instead. Same problem elsewhere; you must *always* explicitly use `self` when referencing an attribute of the current object. Python !=3D Java or C++. Cheers, Chris