[Python-bugs-list] [ python-Bugs-411996 ] no "_" variable with displayhook
noreply@sourceforge.net
noreply@sourceforge.net
Wed, 28 Mar 2001 20:00:44 -0800
Bugs item #411996, was updated on 2001-03-28 12:09
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=411996&group_id=5470
Category: None
>Group: Not a Bug
Status: Open
Priority: 5
Submitted By: Nobody/Anonymous (nobody)
Assigned to: Nobody/Anonymous (nobody)
>Summary: no "_" variable with displayhook
Initial Comment:
after using the new displayhook function, the "_"
variable is no longer functional.
>>> # Create a recursive data structure
... L = [1,2,3]
>>> L.append(L)
>>> L # Show Python's default output
[1, 2, 3, [...]]
>>> # Use pprint.pprint() as the display function
... import sys, pprint
>>> sys.displayhook = pprint.pprint
>>> L
[1, 2, 3, <Recursion on list with id=135143996>]
>>> a = 1./4
>>> _
[1, 2, 3, <Recursion on list with id=135525660>]
----------------------------------------------------------------------
>Comment By: Tim Peters (tim_one)
Date: 2001-03-28 20:00
Message:
Logged In: YES
user_id=31435
Sorry, but setting "_" is done by the system-default
display hook. If you replace the default display hook, you
lose it. If you still want it, you have to implement it in
*your* display hook (by assigning to __builtin__._ when you
want its value to change).
Note that the example you gave is a bad one, because an
assignment statement doesn't trigger the display hook
anyway. That is, "a = 1./4" would have had no effect on _
even if you hadn't replaced the display hook.
----------------------------------------------------------------------
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=411996&group_id=5470