Peng Yu <pengyu...@gmail.com> writes: > R has the function edit() which allows the editing of the definition > of a function. Does python have something similar so that users can > edit python functions on the fly? Thanks.
That would depend on which interactive tool you're using. The typical Python REPL [0] tools – interactive ‘python3’, the enhanced ‘ipython3’ tool, and so on – do not, to my knowledge, retain the source code that you enter. They pass it immediately to the Python compiler, and receive back the compiled code object, and use that. The source code is discarded by the time the code is run. So any tool that does what you propose will need to keep that source code around indefinitely, in anticipation of being asked to edit and re-compile it. I think you're asking not for a REPL, but a tool at a higher level known as an IDE [1]. You can use any good IDE, such as Emacs, to edit code and run it interactively. [0] Read, Evaluate, Print, then Loop. [1] Interactive Development Environment. -- \ “I find the whole business of religion profoundly interesting. | `\ But it does mystify me that otherwise intelligent people take | _o__) it seriously.” —Douglas Adams | Ben Finney -- https://mail.python.org/mailman/listinfo/python-list