Re: v1.0.2 question

tnb2d@henson.cs.virginia.edu
Wed, 4 May 94 16:15:58 EDT

At the same time Guido proposed '_' as the value of the last
printed expression, I believe he also proposed a list of the
previously printed values that would be stored in something like
'sys.last' so 'sys.last[-1]' would be the last printed value. This
sounds like the only thing we'd need, so we can trash this
recursion-causing '_' variable and just store the last-value in
sys.last. Or maybe last would be the list of values and we could have
a separate var (sys.last_value?) to store the VERY last value printed.

Tim Peters writes:
| > [tommy]
| > ...
| > Python 1.0.2 (May 4 1994)
| > Copyright 1991-1994 Stichting Mathematisch Centrum, Amsterdam
| > >>> vars()
| > {'__name__': '__main__', '_': {'__name__': '__main__', '_':
| > {'__name__': '__main__', '_': {'__name__': '__main__', '_':
| > {'__name__': '__main__', '_': {'__name__': '__main__', '_':
| > ... endless repetitions
|
| > The output I got was not what I expected. Was this a bug?
|
| Maybe not strictly, but it is a hoot <grin>! The new feature is that '_'
| is automatically set to the result of the last auto-printed expression.
| So I think what's happening is:
|
| 1) vars() returns the namespace N == {'__name__': '__main__'}.
|
| 2) The auto-printer '_' hack binds '_' to N before printing, which
| changes the namespace to N == {'__name__': '__main__, '_': N}.
|
| 3) The attempt to print N == {'__name__': '__main__, '_': N} then falls
| into infinite recursion.
|
| At least that matches the symptoms.
|
| speculatingly y'rs - tim
|
| Tim Peters tim@ksr.com
| not speaking for Kendall Square Research Corp

-------> Tommy.

"Subvert the parental paradigm - Refuse Birth."