Skip to content

Allow global namespace #5

@iamanigeeit

Description

@iamanigeeit

Every code block runs in its own scope currently, so if i have multiple code blocks on a single page i have to redefine everything above. So:

def hello():
    print('Hello')

Then:

hello()

will not work.

I understand this is by design (brython-dev/brython#690) but for documents we should enable global namespace.

I patched this in brython_runner.py

window.__BRYTHON__.user_namespace = {}
ns = window.__BRYTHON__.user_namespace

before def run().

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions