• Login or register

discuss.effbot.org

  • Popular
  • Recent
  • Importing Python Modules (effbot.org)
    1 point by effbot 1 year ago
    • 3 comments
  • 1 point by zeevneumeier 7 months ago 0 children

    Beware of circular imports!
    I just spent 24 hours of my life debugging this so watch out. Circular imports do some very strange things. In my case we have some singelton instances that suddenly stopped being singeltons (i.e. they re-instantiated on every run) all because someone added a circular import. So now you know.

    • link
    • reply
  • comment deleted
    • 1 point by effbot 1 year ago 1 child

      It doesn't support file paths. It does support package names, but it doesn't really do what you expect: __import__('X.Y.Z') will indeed import the X, X.Y, and X.Y.Z modules and install them in sys.modules, but the function returns the X package module instead of the Z module.

      Also see: http://effbot.org/zone/import-string.htm

      • link
      • reply
      • 1 point by tepples 1 year ago 0 children

        "The Module Documentation Tells You To Use from-import"

        Examples of this would include everything in __future__.

        • link
        • reply
  • Widget
  • Recent Comments
  • Leaders
Powered by