> > Please try this again on various platforms with this version: > > > > i = 0 > > class C: > > def __getattr__(self, name): > > global i > > print i > > i += 1 > > return self.name # common beginners' mistake > > > > C() # This tries to get __init__, triggering the recursion > > > > I get 5788 iterations on Red Hat Linux 6.2 (ulimit -c says 8192; I > > have no idea what units). > > 8192 refers to kB, i.e. 8 MB. > > I get 6053 on SuSE Linux 6.2 without resource stack limit set. > > Strange enough if I put the above inside a script, the class > isn't instantiated. The recursion only starts when I manually > trigger C() in interactive mode or do something like > 'print C()'. Is this a bug or a feature ? Aha. I was wrong -- it's happening in repr(), not during construction. --Guido van Rossum (home page: http://www.pythonlabs.com/~guido/)
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4