Next: Parallel Execution, Up: Miscellaneous [Contents]
When defining multi-line code blocks as strings, the identation on the
first line may be distracting. However, adding a newline to #:code
will also mean a newline appears whenever #:code
is printed. For
convenience, a chomp
function is provided as a lightweight wrapper
around the string-trim
family of functions that only removes
newlines.
(define-block foobar #:code (chomp " import random def get_chance(percent: int = 10) -> bool: \"\"\" Return true a given percent of the time. Defaults to 10%. :type percent: int The percent chance to return true. :return: bool. \"\"\" value = random.randrange(100) return value < percent ") #:language python)