Python:Script

From PrattWiki
Revision as of 23:45, 5 September 2018 by DukeEgr93 (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Python has a feature that lets you put code inside a text file that Pythoncan then access and run as if the code were typed into the command line.

This structure is good for writing the "big picture" code that coordinates all the computational tasks. Scripts can have functions defined in them and can call other scripts.

Syntax

To create a script, all you have to do is edit a text file whose name starts with a letter, contains letters and numbers (and possibly the underscore character), and ends in .py

Spyder Help File

To make a help file that Spyder's help pane will see, note that Spyder will assume the first comment block (between the triple " at the top) is the help file. Type your helpfile in that section. While running Spyder, if Spyder can see your .py file, just go to the help pane and type the script's name - Spyder will display the comments.


Questions

Post your questions by editing the discussion page of this article. Edit the page, then scroll to the bottom and add a question by putting in the characters *{{Q}}, followed by your question and finally your signature (with four tildes, i.e. ~~~~). Using the {{Q}} will automatically put the page in the category of pages with questions - other editors hoping to help out can then go to that category page to see where the questions are. See the page for Template:Q for details and examples.

External Links

References