stupid question about Mac OS X and python

kc2ihx

Registered
I started to look into python today and have been using it in the terminal app, however I would like to be able to use textedit, nedit or emacs to type up a source file. How would I go about doing this? I am using os X.2. It would be a real help.

KC2IHX
 
Thank you for the information however, my problem is not with the editor (and I don't have BBEdit anyway), i am using a application called Nedit that supports python, but my problem is with the python compiler/interpreter. My question is somewhat ambiguous. A better question is how do I get it to run the contents of a text file (saved as a .py file not txt) from a program like Nedit, TextEdit, or emacs.
 
In emacs, you can type Escape, x, shell-command, enter, then enter a command that runs your script. Option-x works for Escape-x if you have enabled the appropriate "Use option key as meta key" option in Terminal, or if you are using the OS X GUI port of emacs.
 
Well, that would be your python program. Mine is /usr/bin/python, use 'where python' in tcsh or 'type python' in bash to find out where yours is. In fact, if you set your script file up right with #!/usr/bin/python as the first line, with execute permissions (chmod u+x script.py), you can just execute the script file with shell-command.
 
If you want to be slightly less dependant on where python is installed you can also use:
#!/usr/bin/env python

this will work on most *nix setups.

C
 
Back
Top