Wits end relief

Alex Martelli aleaxit at yahoo.com
Mon Nov 13 04:23:40 EST 2000


"Brendhan Horne" <brendhanhorne at bellsouth.net> wrote in message
news:4lGP5.1125$035.30955 at news2.mia...
    [snip]
> And Now for something completely different:
> At A python command line prompt >>> How do I save a few lines I have
written
> to a file? Without using textpad or any other text editor. I want to save
it
> from python's command line >>>.

You can get whatever text is showing on the console (or part of
it) onto Windows' "Clipboard", with Windows' normal mechanisms
for that purpose; but saving the text from the clipboard onto a
file requires using a program.  Doesn't have to be a text editor
(the "Clipboard viewer" aka "Clipbook viewer" that is one of
Windows' "Accessories" can help, for example, although it's not
able to save textfiles in all versions), but it must be some
program able to read text from clipboard and write it to file.

These are not really Python issues, although one might use
Python (with win32all) to implement the save-clipboard-to-file
program (but it's a rather advanced issue, and I would not
suggest you tackle it).

On Unix, the python interactive interpreter is normally
compiled with the "readline" module, which keeps a "history"
of the lines entered, and you could use to perform directly
the task you require.  However, this is not a built-in part
of the Windows version of Python.
(There are some Windows versions of the readline Python module
which you could download, but I don't think the interactive
interpreter would use them anyway unless you re-built it).

I think this is not perceived as an issue of substantial
importance because development-work (which could benefit
from history management) for Python on Windows is normally
done in such environments as IDLE or PythonWin, which supply
their own history-management anyway.


Alex






More information about the Python-list mailing list