[Tutor] How to get a script to open a text file with Python?
rdm at rcblue.com
Wed Jun 11 01:59:05 CEST 2008
At 03:44 PM 6/10/2008, Alan Gauld wrote:
>"Dick Moores" <rdm at rcblue.com> wrote
>>The script prints into the Windows command line
>>window (I don't know the official term), from which
>>copying is a PITA.
>Whats the problem copying from a command prompt?
1. Click on the little black icon in the upper left corner.
2. Select Edit.
3. Select Mark
4. Select text to copy
5. Hit Enter
>Just grab with the mouse and it's selected automatically
>(assuming you have QuickEdit mode turned on in the
Big assumption! I've been doing the above 5-step dance for years
because I didn't know about QuickEdit. Thanks, Alan.
How about pasting INTO the command prompt. Ctrl+V doesn't work, even
> I copy/paste from a DOS box
>into my mail messages regularly.
>>Now, the script writes into temp.txt, so I thought if
>>I could also have Textpad open temp.txt, I could copy easily.
>You could. But why do you need to copy it at all?
>Couldn't you get Python to do what you want with the
>data directly rather than writing to a file then manually
Looking at the script now, I think I could.
>>But I don't know how to have a script get Textpad
>>to open a file. Please tell me.
>If TextPad is your default txt editor just use
>os.system("foo.txt") or if not use os.system("Path/to/textpad.exe foo.txt")
Thanks for this.
>Or if you want to be politically correct use the subprocess module
>to do the same thing.
Nah. Or I don't think I do. Why is it the correct way? Is there a
problem with yours?
More information about the Tutor