Code

Execute code in an event.

SEL has built-in support for running blocks of code using the following syntax:

"my_code": =Code(```python

print ("Hello, world!")

```)

Note the following:

  • The entire code block should be placed inside triple ` marks.
  • The language of choice should follow the first ```.

While in experimental mode, rather than a return statement, Code events return values using a single print statement.

Supported languages: python, php, javascript, typescript, and ruby.

PHP code should be wrapped in <?php ?> inside the code block.

"my_php": =Code(```php

<?php

echo "Hello, world!";

?>

```)

🚧

Casting

If the printed object can be turned into a valid dictionary, number, list, or string, it will be. These objects may only contain literals (not executable code). If a printed object cannot be converted into a literal representation, it will simply return its string representation.

Libraries

In addition to each language's standard library, the following libraries may be imported.

LanguageLibrariesVersion
PythonStandard, plus requests, numpy, pillow3.12.0
JavaScript / TypeScriptStandard, plusfetch, JSONBoa, TypeScript via wsc
PHPStandard-only8.2.6
RubyStandard-only3.3.0