Can a simple a==b 'hang' in and endless loop?
Fuzzyman
fuzzyman at gmail.com
Thu Jan 19 09:34:12 EST 2006
Claudio Grondi wrote:
[snip..]
> Wow! I haven't got this evil idea myself yet (even if as I understand
> there is no problem to achieve similar thing also in C), so I have
> learned a bit more about Python again. Am I right supposing, that this
> becomes possible because the .append() goes not that far to try to
> generate the actual list (getting trapped in the endless loop) and only
> lets the second list element point to the object with the list itself.
I think you've got this.
a = []
Here a is a reference to a list object.
a.append(a)
As mentioend previously - you pass around references (names), not
values.
Here you've put a reference to the list object a as the first member of
the list a.
> The trouble with it becomes apparent later when working with such bad
> defined list as it is the case when applying the '==' operator to it.
> Thank you for sharing this with me, but again ...
>
> this is still _not_ what I am looking for, because Python detects here
> the problem and throws an exception. What I am looking for is an endless
> loop where there is no any response from Python about a problem.
>
Loops tend to be caused by function or method calls - so they add
frames to the stack and get detected as recursion.
All the best,
Fuzzyman
http://www.voidspace.org.uk/python/index.shtml
> Claudio
More information about the Python-list
mailing list