Search Results

Search found 1 results on 1 pages for 'ieure'.

Page 1/1 | 1 

  • Why does Python's __import__ require fromlist?

    - by ieure
    In Python, if you want to programmatically import a module, you can do: module = __import__('module_name') If you want to import a submodule, you would think it would be a simple matter of: module = __import__('module_name.submodule') Of course, this doesn't work; you just get module_name again. You have to do: module = __import__('module_name.submodule', fromlist=['blah']) Why? The actual value of fromlist don't seem to matter at all, as long as it's non-empty. What is the point of requiring an argument, then ignoring its values? Most stuff in Python seems to be done for good reason, but for the life of me, I can't come up with any reasonable explanation for this behavior to exist.

    Read the article

1