Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

question: how to use install() #59

Closed
wwdok opened this issue Mar 25, 2022 · 1 comment
Closed

question: how to use install() #59

wwdok opened this issue Mar 25, 2022 · 1 comment

Comments

@wwdok
Copy link

wwdok commented Mar 25, 2022

I created two python file to play with the install() feature:

temp1.py:

from objprint import op, install

# Now you can use op() in any file
install()

temp2.py:

op("hello")

But run the temp2.py, it throws error : NameError: name 'op' is not defined
What is the correct usage of install() ? Thanks !

@gaogaotiantian
Copy link
Owner

There's no magic across interpreters. install() basically adds op to builtins so that it could be used in the SAME interpreter process elsewhere. In this case, in the temp2.py, you need to import temp1 so the install() executes before you try to use op. The feature saves you some imports when you have many files in your project.

@wwdok wwdok closed this as completed Mar 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants