Skip to content

Instantly share code, notes, and snippets.

@jameswritescode
Created July 29, 2015 15:31
Show Gist options
  • Select an option

  • Save jameswritescode/ba01b12859b2fe9d1952 to your computer and use it in GitHub Desktop.

Select an option

Save jameswritescode/ba01b12859b2fe9d1952 to your computer and use it in GitHub Desktop.
# Each container has their own state
container1 = ScriptingContainer();
container2 = ScriptingContainer();
container1.set('x', '1234') # or just .eval('x = 1234')
container2.set('x', '2345') # ^
container1.get('x') # => 1234
container2.get('x') # => 2345
# Apparently this won't actually work with a `eval`, but just to illustrate another bit:
code = """
class Person:
def __init__(self):
print('hy')
"""
container1.eval(code)
container1.get('Person') # => <class '__main__.Person'>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment