This quick set of steps demonstrates how to
set up your workspace for a Python project.
-
In Visual Studio Code, save your new workspace to a convenient location.
For example, C:/OS_Py/OpenSTAAD_Python_Tutorial.workspace.
The workspace in Visual Studio Code serves as your working folder for saving and executing code.
-
Create a new file.
-
Save the file with a “
.py
” file
extension.
This automatically instructs Visual Studio Code to interpret the input as
Python.
Note: If you did not previously install the Python extension, then
the program prompts you to do so. Also, if you have not previously installed
a linter and code completion option, then the program prompts you to do so.
These are recommended.
-
In the main editor window, begin typing commands.
For example, type print("Hello World!").
-
Select the Run tool to execute your code.
The terminal will open and display the results.
-
Save your code.
While having your computer return “Hello World!” may be a classic example of a
first program, it is not a very practical tool. However, you now have a file set up to
create a more useful OpenSTAAD project in your next
example.