3 ms·
If you just want to accio act as import, you can always do this: accio = __import__ Anyway, interesting article!
by daGrevis 13y ago
If you just want to accio act as import, you can always do this:
accio = __import__
Anyway, interesting article!
- jodrellblank 13y agoRead the article, that was discussed and dismissed. It doesn't make accio 'act as import' because import is a keyword not a function call.
- daGrevis 13y agoimport is a statement. __import__ is a function hence will work. In [1]: accio = __import__ In [2]: accio("os") Out[2]: <module 'os' from '/usr/lib/python2.7/os.pyc'>
- raimondious 13y agoFrom the article... >>> accio = __builtins__.__import__ >>> accio sys File "<stdin>", line 1 accio sys ^ SyntaxError: invalid syntax # :( The author wanted accio to replace import not __import__.