[ python-Feature Requests-852222 ] builtin save() function available interactively only

SourceForge.net noreply at sourceforge.net
Thu Jan 22 10:17:07 EST 2004


Feature Requests item #852222, was opened at 2003-12-01 13:13
Message generated for change (Settings changed) made by rhettinger
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=355470&aid=852222&group_id=5470

Category: Python Library
Group: None
>Status: Closed
>Resolution: Wont Fix
Priority: 5
Submitted By: Gerrit Holl (gerrit)
Assigned to: Nobody/Anonymous (nobody)
Summary: builtin save() function available interactively only

Initial Comment:
I think that for learning python, it would be nice to
save the current namespace to a file using a builtin
save() function (and corresponding load(). For
beginning programmers, it would be nice to be able to
tinker interactively with the shell, defining functions
and maybe even classes, with which they can continue
later on. save() is easily implemented with pickling
locals(); load() is easily implemented with updating
locals() while unpickling it. The functions would take
a filename (string) as an argument. In Idle, they are
in the menu. Like the _ variable, load() and save() are
only present in the interactive shell (some global
.pythonrc?). I think it would be a useful addition to
Python 2.4.

----------------------------------------------------------------------

Comment By: Raymond Hettinger (rhettinger)
Date: 2004-01-01 01:01

Message:
Logged In: YES 
user_id=80475

Yes, that would be nice but it exceeds the capabilities of
pickle which only saves function and class names rather than
values:

>>> def f(x, y, z):
        m = min([x, y, z])
        n = max([x, y, z])
        p = m * n
        q = p ** 0.5
        return q / y

>>> pickle.dumps(f)
'c__main__\nf\np0\n.'


It may be possible to save the interpreter window as a text
file to be replayed later after the prompts and results have
been stripped.

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=355470&aid=852222&group_id=5470



More information about the Python-bugs-list mailing list