[Tutor] Is implicit underscore assignment documented?

2006-07-07 Thread Terry Carroll
Is implicit underscore assignment documented anywhere?  I've seen 
reference to this, and it seems to be simply that, when Python 
interactively prints a value in response to a user entering an expression, 
that value is assigned to the variable _.  

As far as I can tell, the following transcript shows its workings:

ActivePython 2.4.3 Build 12 (ActiveState Software Inc.) based on 
Python 2.4.3 (#69, Apr 11 2006, 15:32:42) [MSC v.1310 32 bit (Intel)] on win32
Type help, copyright, credits or license for more information.
 _
Traceback (most recent call last):
  File stdin, line 1, in ?
NameError: name '_' is not defined
 a = 0
 _
Traceback (most recent call last):
  File stdin, line 1, in ?
NameError: name '_' is not defined
 a
0
 _
0

 a = 5
 _
0
 a
5
 _
5
 a = 5
 _
0
 a
5
 _
5
 #value unchanged, because a's value was not printed (the interpreter 
does not print None).
...
 a = 10
 print a
10
 _
5
 # value unchanged, because print is a statement, not an expression.
...


Is this documented anywhere?

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Is implicit underscore assignment documented?

2006-07-07 Thread Terry Carroll
On Fri, 7 Jul 2006, Terry Carroll wrote:

 As far as I can tell, the following transcript shows its workings:

Orri has privately pointed out to me that I have a copy-paste error in the 
transcript; but that aside, my question still is:

 Is this documented anywhere?

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor