If you need to write whole classes in Python:
Download TextWrangler, open it, and adjust the bars at the bottom to say Python, Unicode (UTF-8) and Unix (LF). When you are done, save the file as (filename).py. TextWrangler is my favorite app to write code in because you can pick the Monaco font (my favorite) and it colors the code based on what you wrote.
To test the file click on the #! in the menu bar at the top and either click “Run” or “Run in Terminal.” This will run through your code and catch errors. If you have defs (functions, methods, whatever you call them) in a class, they are hard to run. Test the defs by running your class and calling the defs you want to test at the zero-indent level. If the defs still don’t run, set them equal to a value. So say you want to test the function
def kevin (b):
right below it, with no indent, write
a = kevin(“jeff”)
and then see if it prints “jeff” when you run the code. I couldn’t figure out how to run the defs straight from a command line.
The other way to test your code is by interactions. To test interactions (one line of code at a time, with a prompt line) open Terminal (in Finder open Applications, then open Utilities) and type python, then hit “Return.” Some dialog should come up and then there should be three arrows like this
This means that you can now type Python code and test it. Running code and testing it in interactions are the two main ways to write and test your code.
If you have to test Regular Expressions (if you don’t know what they are, don’t ask), follow the instructions here to download MacPython. Once you’ve done that, find the file redemo.py and run it. It lets you edit a regular expression and a string to match it against in real time.