Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!xlned.com!feeder1.xlned.com!newsfeed.xs4all.nl!newsfeed1.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.006 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; '21,': 0.07; 'none,': 0.07; 'instances.': 0.09; 'iterate': 0.09; 'cc:addr:python-list': 0.11; 'def': 0.12; 'jan': 0.12; '0))': 0.16; '9:20': 0.16; 'assigns': 0.16; 'class),': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'lower-case': 0.16; 'node,': 0.16; 'subject:class': 0.16; 'wrote:': 0.18; 'things.': 0.19; 'cc:addr:python.org': 0.22; 'print': 0.22; 'cc:2**0': 0.24; 'header:In-Reply-To:1': 0.27; 'robert': 0.30; 'message- id:@mail.gmail.com': 0.30; '(which': 0.31; 'code': 0.31; 'letter.': 0.31; 'node': 0.31; 'second,': 0.31; 'probably': 0.32; 'problem': 0.35; 'skip:s 30': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'instances': 0.36; 'two': 0.37; 'pm,': 0.38; 'expect': 0.39; 'problems.': 0.60; 'solve': 0.60; "you're": 0.61; 'first': 0.61; 'name': 0.63; 'more': 0.64; 'different': 0.65; 'line,': 0.68; 'to:none': 0.92 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:cc :content-type:content-transfer-encoding; bh=5fONRAidY4/QQEASrvItzoCVkgQXAqdv2nfWsxRgTes=; b=ipALQyZ8gAgRlcmEuyXv4F0qf7LzDjDvRi4B8SteK9H2oJW7YQd8CFZFvtCvG3wMNZ mhuXX04vtC0rLvb+dFd6uCkxUto3T73khABheDUlne1qC9EVxPWLNInAX4Hr+ZCq+h3W Ut+r8N02jVHmX+PF/wcxp/y6XOBPCNEGSzYmLOanFrD6lB7Z15/C4/6qXJNdX8PZsd20 83xKAhR9Iw70Kdwdk1f+uhHYlXXASNx5TrPx7vS1r7Q0dlgQB5PfOcFwetM9g8TBbweI 1vrEIK7v8in831yFVeTDU1nU5DGPIBkH2Mx+QcVGU2nJ1sutLPppBS3iO385tGZ3h7vx QAXA== MIME-Version: 1.0 X-Received: by 10.68.201.10 with SMTP id jw10mr24200134pbc.25.1390301236002; Tue, 21 Jan 2014 02:47:16 -0800 (PST) In-Reply-To: <8abb6a72-c258-4f08-a391-867d2680591d@googlegroups.com> References: <8abb6a72-c258-4f08-a391-867d2680591d@googlegroups.com> Date: Tue, 21 Jan 2014 21:47:15 +1100 Subject: Re: use class in class From: Chris Angelico Cc: "python-list@python.org" Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable 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: 17 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1390301245 news.xs4all.nl 2831 [2001:888:2000:d::a6]:51465 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:64396 On Tue, Jan 21, 2014 at 9:20 PM, Robert Voigtl=C3=A4nder wrote: > def calcRoute(self): > self.openlist.append(Node(self.start, None, 0, 0)) > for Node in self.openlist: print Node.pos, Node.parent, Node.g, N= ode.h, Node.f You're using the name Node to mean two different things. In the first line, you expect it to be the global name (which is the class), but on the second, you want to iterate over the node instances. That assigns to the name Node, which causes your problems. I recommend using a different name for the instances here, probably with a lower-case first letter. That would solve your problem _and_ make your code more readable. ChrisA