Results 1 to 3 of 3

Thread: Python and Dynamic Imports

  1. #1

    Python and Dynamic Imports

    I'm wanting to import a specific class via a choice thats made by the user. The following is the flawed code that I came up with (but doesn't 'compile' ...)

    Code:
        def packageSelect(self, event, package):
            self.package_type = package
            import ("%s" % ("" + LIB_PATH + self.package_type + "_package.py"))
            return package
    I would also like to remove the class if that is possible on demand as well.

    Any ideas?

  2. #2

    Re:Python and Dynamic Imports

    No ideas?

  3. #3

    Re:Python and Dynamic Imports

    Truth be told I"ve never seen this done.

    Does this help?

    http://forums.devshed.com/t180067/s.html
    http://mail.python.org/pipermail/pyt...ay/222723.html

    I just googled for 'python "conditional import"' and 'python dynamic import'

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •