[Python-Dev] adding save() and load() function for interactive use (original) (raw)
Gerrit Holl gerrit at nl.linux.org
Mon Dec 1 13:30:30 EST 2003
- Previous message: [Python-Dev] Re: "groupby" iterator
- Next message: [Python-Dev] adding save() and load() function for interactive use
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Hello,
I have a proposal to enhance the usefulness of Python for learning purposes. RFE#852222:
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 by pickling locals(); load() is easily implemented by updating locals() while unpickling it. The functions would take a filename (string) as an argument. In Idle, they could be in the menu. Like the _ variable, load() and save() are only present in the interactive shell (some global .pythonrc?). Example usage:
def foo(): ... raw_input("Do you like it?" ) ... print "Great!" save("~/session")
load("~/session") foo() Do you like it? yes Great!
Note that this code is untested.
I think this would be a nice addition to Python 2.4.
yours, Gerrit.
-- 105. If the agent is careless, and does not take a receipt for the money which he gave the merchant, he can not consider the unreceipted money as his own. -- 1780 BC, Hammurabi, Code of Law
Asperger's Syndrome - a personal approach: http://people.nl.linux.org/~gerrit/english/
- Previous message: [Python-Dev] Re: "groupby" iterator
- Next message: [Python-Dev] adding save() and load() function for interactive use
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]