This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: builtin save() function available interactively only
Type: enhancement Stage:
Components: Library (Lib) Versions:
process
Status: closed Resolution: wont fix
Dependencies: Superseder:
Assigned To: Nosy List: gerrit, rhettinger
Priority: normal Keywords:

Created on 2003-12-01 18:13 by gerrit, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (2)
msg54071 - (view) Author: Gerrit Holl (gerrit) Date: 2003-12-01 18:13
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.
msg54072 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2004-01-01 06:01
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.
History
Date User Action Args
2022-04-11 14:56:01adminsetgithub: 39639
2003-12-01 18:13:17gerritcreate