In the terminal you can run your python programs:
Go To Applications->Accessories->Terminal
python yourprogramhere.py
Note you need to be in the same directory as your python program, otherwise you need to type:
python /fulldirectorypath/yourprogramhere.py
or
python ./remainingdirectorypath/yourprogramhere.py
if you only type python at the prompt then you enter into the python program where it expects you to code in python commands at that point and time. Don't do this instead code your python programs in the text editor and run them with the python command.
Tip you can cycle through your previously typed commands in Linux by hitting the up and down arrows on the keyboard at the prompt.
Go To Applications->Accessories->Text Editor
in the Text Editor go to View->Highlight Mode->Scripts->Python
in the Text Editor go to Edit->Preferences
in Preferences make sure the following is checked:
in the View Tab
Text Wrapping All Options Checked
Display Line Numbers Checked
Highlight Current Line Checked
Display Right Margin Checked and leave it at 80
Highlight Matching Bracket Checked
in the Editor
Tab Width leave it at 8
Insert Spaces Instead of Tabs DO NOT CHECK!!!! This will keep your python programs from running correctly do to the fact that it relies on tabs for the begin and ending parts of code blocks such as functions, condition statements, etc.
Enable Automatic Indentation Checked.
File Saving Check All
in the Font & Color Tab
Use The System Fixed Width Font Do Not Check.
Now you can select a larger font which will make it easy to read your code and debug faster.
Now you are ready to code your program in Python in the text editor and save your file with the extension .py
After you save your file test the program in the terminal with your python command as explained up above. If you make a syntax error you will get detailed messages of what the problem is and what line the error is on. The error messages are better in the terminal than they are in Idle.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment