Improved code compilation pattern, closes #472

This commit is contained in:
Simon Willison 2022-08-26 22:20:09 -07:00
commit a46a5e3a9e
3 changed files with 24 additions and 8 deletions

View file

@ -1359,12 +1359,9 @@ The following example adds a new ``score`` column, then updates it to list a ran
random.seed(10)
def convert(value):
global random
return random.random()
'
Note the ``global random`` line here. Due to the way the tool compiles Python code, this is necessary to ensure the ``random`` module is available within the ``convert()`` function. If you were to omit this you would see a ``NameError: name 'random' is not defined`` error.
.. _cli_convert_recipes:
sqlite-utils convert recipes