so I'm upgrading my package structure. I finally found out that by importing with __import__ instead of the regular import, I don't have to know the name of the package before hand. Here's the problem: the original code works:
import top_pkg.desc_pkg import fact def fun(): [INDENT]top_pkg.desc_pkg.cls = fact.new() [/INDENT]but the new version does not:
mod_name = __import__(__name__) import fact def fun(): [INDENT]mod_name.cls = fact.new() [/INDENT]Both of the code's are in a package's __init__.py. For some reason when later calling the module's cls-attribute, it doesn't exist.
Any ideas why ??


Sign In
Create Account


Back to top









