Skip to content

Imports not working in functions, classes #7

@susnicek

Description

@susnicek

Dear developers,
I am new in pybind11 and I encountered following simple problem: consider the example "eval-file" - if I change the script "set-the-y.py" as follows:

import sys

def print_version():
	print(sys.version)

print_version()

set_the_answer(y - 1)

I got an error in function 'print_version'

NameError: name 'sys' is not defined

This is very strange for me, please can anybody explain me what is wrong? How to make the code above operational?
Thank you in advance for your replies! Susnicek

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