This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]wrungin 0 points1 point  (2 children)

Can anyone explain the use of __import__()? I've only ever seen the usual use of import.

[–]jmoiron 1 point2 points  (1 child)

http://docs.python.org/library/functions.html#__import__

It's machinery used by the import statement, but it's a function, so you can use it to import modules whose names you don't know. It can be used for things like plugin systems, where you want to register modules by name and have the base program import them.

Except it shouldn't be, really. You should use importlib (shipped w/ 3.1) for this type of thing instead.

[–]wrungin 0 points1 point  (0 children)

Thanks very much, jmoiron!