Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.albasani.net!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.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'attributes': 0.05; 'attribute': 0.07; 'infinite': 0.07; 'invokes': 0.09; 'loop.': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:80.91.229.12': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'received:lo.gmane.org': 0.09; 'def': 0.13; 'tries': 0.15; '@property': 0.16; 'attribute,': 0.16; 'crashes': 0.16; 'numpy': 0.16; 'received:dip.t-dialin.net': 0.16; 'received:t-dialin.net': 0.16; 'wrote:': 0.18; 'endless': 0.18; 'idea?': 0.18; 'from:addr:web.de': 0.23; 'stack': 0.24; 'class': 0.29; 'header:X-Complaints-To:1': 0.33; 'named': 0.33; 'to:addr :python-list': 0.34; 'skip:" 10': 0.37; 'replace': 0.38; 'received:org': 0.38; 'some': 0.38; 'to:addr:python.org': 0.40; 'type': 0.61; 'kind': 0.61; 'happen': 0.61; 'recursion.': 0.84; 'subject:Class': 0.84 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Peter Otten <__peter__@web.de> Subject: Re: Class: @property -> .__dict__ Date: Fri, 16 Dec 2011 10:32:45 +0100 Organization: None References: <4eeb0949$0$29979$c3e8da3$5496439d@news.astraweb.com> <3fe1021b-75ae-4e3d-a5b0-175ad00aefa4@i6g2000vbh.googlegroups.com> <08b0a976-dd2a-4728-b865-4d04f4e5b7fb@n10g2000vbg.googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 7Bit X-Gmane-NNTP-Posting-Host: p5084b384.dip.t-dialin.net 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: 1324027975 news.xs4all.nl 6888 [2001:888:2000:d::a6]:50933 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:17342 Ulrich wrote: > if I replace it to > def attributelist(self): > # find all attributes to the class that are of type numpy > arrays: > return [attr for attr in dir(self) if > isinstance(getattr(self, attr), numpy.ndarray)] > > it crashes going into some kind of endless loop. > > Do you happen to have any idea? dir(self) finds an attribute named "attributelist", getattr(self, "attributelist") then tries to calculate the value of that attribute, invokes dir(self) which finds an attribute named "attributelist" and so on ad infinitum or the stack overflows. Try (untested) @property def attributelist(self): return [attr for attr in dir(self) if attr != "attributelist" and isinstance(getattr(self, attr), numpy.ndarray)] to avoid the infinite recursion.