Difference: UsingPython ( vs. 1)

Revision 12013-03-30 - gslayden

Line: 1 to 1
Added:
>
>
META TOPICPARENT name="WebHome"

On a Windows PC, using the command line

  • Make sure your 'path' environment variable points to your Python executable (perhaps C:\Python25).
    See this page for instructions on how to set the path variable in XP.
    In Vista, find the control for setting environment variables in 'Start/Control Panel/System and Maintenance/System' and select "Advanced system settings".
  • Use notepad to save a copy of the script you're modifying, with a .py extension, in the directory of your choice.
    (e.g. "C:\My Documents\Ling472\Assignment 1\elizalike.py")
  • Open a command prompt: From the start menu either
    select 'All Programs/Accessories/Command Prompt', or
    select 'run', and type "cmd" in the window that pops up.
  • type "cd" followed by the path to the directory containing your copy of the script.
    (e.g. "cd C:\My Documents\Ling472\Assignment 1")
  • To run the script, type "python filename.py" in the command window.
  • Edit your script, save it, and test it again with "python filename.py".

On a Windows PC, using the Graphical User Interface

Note: this works best for scripts that do not take any arguments.

  • Save a copy of the script you're modifying, with a .py extension, in the directory of your choice.
  • Associate the .py extension with the Python Interpreter:
    In your directory, select 'Folder Options' from the tools menu.
    In the File Types tab, click 'New', and enter the extension 'py'
    click 'Change' and select the Python Command Line Interpreter
  • To run the script, double click it.

On Dante or one of the Treehouse machines

  • Log in to Dante using ssh and type S at the initial screen to get a shell.
  • Or login to a Treehouse workstation.
  • Make a directory for your scripts: mkdir pythonscripts
  • Go to that directory: cd pythonscripts
  • Make a copy of the starter script you're working on. Save it with a .py extension.
  • Use a text editor such as emacs or pico to edit the script.
  • To run a script type

    python filename.py
  • Edit your script and save it, and run it again to test changes.
  • You may find it helpful to have multiple terminal windows open, at least one for editing the script and one for running it.

On a Mac running OS X

  • Make a directory, say, inside ~/Documents.
  • Save a copy of the python script you're working on in that directory, with the extension .py.
  • Edit the python script with emacs or textedit. (NB: With textedit, you'll need to make sure to save the file as plain text rather than rtf.)
  • To run the script, in your terminal window, type

    python filename.py
  • Edit the script with your favorite text editor, and save it.
  • Run it again from the terminal window to see the effect of your changes.
 
This site is powered by the TWiki collaboration platformCopyright & by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback
Privacy Statement Terms & Conditions