how to compile and run a python file,and how to change a directory in Python25.what should i import first in order to run a python code.like import math and ......
If you are trying to run a python script that is titled my_script.py from the command line (you could alternately double-click the icon but you won't be able to catch any errors), do the following:
# Change into directory containing your script
Now this can be greatly simplified if you add C:\Python25 to your PATH variable. There was a post yesterday about doing just. Once that directory is in your PATH you can simply perform python my_script.py Also for changing directories within Python you want the os module, here's an example:
>>> import os
>>> os.getcwd() # Returns the current working directory
>>> os.chdir( 'C:\\Documents and Settings\\Administrator\\Desktop' )
'C:\\Documents and Settings\\Administrator\\Desktop'
>>> os.listdir( '.' )
['787099A0.219.wd_running.zip', '79950653.826', 'BladeGold.lnk', 'ChassisGold.lnk', 'Clearquest user manual reve.ppt', 'condor_cmds.doc', 'double click on this icon if notes crashes.exe', 'Finances.xls', 'mortgage.txt', 'portals.py', 'SystemX.lnk', 'template.py', 'Things I never Use', 'tkUpdate.py']
You don't have to compile Python programs. It is interpreted/byte compiled, which basically means that it takes care of that. If you are just starting, I would suggest that you use Idle (comes with Python) until you are more comfortable with the language. A somewhat dated link http://www.ai.uga.edu/mc/idle/index.html