Schedule parameters in Python
This page describes Revolution release 4.0.0.
On this page
Hi, I'm Revo
Ask me anything about Revolution. My answers link the pages they come from.
When Python runs as a step in a schedule
(Run Python or
Run Python Script), it
can read and write that schedule’s parameters through revo.parameters:
import revo
count = revo.parameters["PlateCount"] # read by namerevo.parameters["PlateCount"] = count + 1 # write by namedone = revo.parameters.AllPlatesDone # or use the name as an attributerevo.parametersreads and writes the parameters declared on the schedule, so declare a parameter there before a Python step uses it (see Schedule parameters).- The value written must suit the parameter’s type.
- A JSON parameter takes a
dict, alistor astrholding JSON, and is stored as minified JSON text. Reading it returns that text as astr, so usejson.loadsto get the data back. Astrthat is not JSON raisesValueError. - Reads and writes apply to the thread the step runs on.
revo.parametersis available to Python running as a schedule step.
A common use is a decision that needs more than an expression: a Python step works out the answer and writes it to a Boolean parameter, and an If..Else step then branches on that parameter.
Pass a value between blocks
Section titled “Pass a value between blocks”A value one block writes is visible to the blocks after it on the same schedule thread, and a later
schedule step reads it as ${name}. Here the schedule declares a whole-number parameter named
plates sealed, with Input off because the scripts set it. An earlier block seeds the count:
import revo
revo.parameters.plates_sealed = 0 # by its Python nameprint(revo.parameters["plates sealed"]) # or by its real name: the same parameterA later block on the same thread reads it back and branches:
import revo
sealed = int(revo.parameters.plates_sealed or 0)if sealed == 0: print("Nothing sealed yet on this schedule thread.")revo.parameters.plates_sealed = sealed + 1