How can I compile and run a python file (*.py extension)?
On most Unix-like systems, you can use the shebang to tell the operating system which interpreter should be called. You simply put
#!/path/to/python
in the first line of your file, where of course you have to replace "/path/to/" with the path you have on your system. In most cases this would be "/usr/bin/python" or "/usr/local/bin/python". On unix systems you could also look for the path with
"#!usr/bin/env python"
or invoke the command
which python
to find the path. You can then run your program with the command
./yourprogram.py
If it tells you that you do not have permission to do so, you have to use the command
chmod a+x yourprogram.py