Modules working ?
Hey, so again I feel a bit dumb asking a so-basic question, but I wasn't able to have basic modules working:
aa = 'Test'
import a print(a.aa)
Running b.py throws the following error : **AttributeError : 'module' object has no attribute 'aa' **
Any clue about what is going on ?
importstatement caches modules, meaning that if you
import amore than once (even across different scripts) it will only be loaded once. Because Pythonista runs only a single Python process, this means that if you
import a, modify
import aagain, the changes to
awon't be visible right away. In the interactive prompt, run
import a, then
reload(a)to reload the module from
a.py, and then run your
b.pyagain and see if it works.
If that didn't help, see if there are any other files named
a.pythat might be imported instead of the one you want. Pythonista doesn't come with any module named
aby default, but if you have a file
a.pyin your Script Library or site-packages, that might be imported wrongly. If you want to find out where the module
awas imported from, see
It works as expected for me. Try adding
reload(a)line just after the import line. Also, make sure the filename is all lowercase.
Thanks guys, the reload() trick did it !