Python

Write Python code.

See Code Editors for more information on composing code in WayScript.

Inputs

WayScript's python editor lets you reference Variables that exist in your program. To do this, you can reference them through the inputs dictionary.

As an example, let's create a variable called "Location" and set a value of "Brooklyn, NY"

You can reference the Location variable in your python script with this code:

location = inputs[ "Location" ]

More abstractly, you reference any variable with the format:

var = inputs[ "<var_name>" ]

Outputs

You can also output data from your python scripts and turn these into variables that can be used by other Modules in your program.

You can do this with the outputs dictionary in the following format:

outputs[ "<Var Name>" ] = variable
# example
from datetime import datetime
outputs[ "Date" ] = str( datetime.today() )

Running Python

While working on your script, you can press the "Run Code" button inside the Python module to run the Python code and see updated results.

Adding Additional Requirements

The Python module comes with many pre-installed Python Libraries. However, if you would like to use a module that isn't already installed, you can declare those requirements in the "Requirements" field.

Declare these requirements as you would in a pip Requirements File, using the Requirements File Format.

For faster code execution, only add requirements that aren't already pre-installed in the Python module.