__import__() with packages

Marco Herrn herrn at gmx.net
Sun Apr 4 12:38:54 EDT 2004


Sorry, accidently sent out the unfinished message.

On 2004-04-04, John Roth <newsgroups at jhrothjr.com> wrote:
> m = __import__("spam.eggs")
> eggs = spam.eggs
>
> This will probably also work:
>
> eggs = __import__("spam.eggs").eggs

Thanks,
but in my application I read the names of the modules from a file,
so I do not know them when writing (in this case I wouldn't know the
name 'eggs'). Since the solution from Paul works for me, I will use
that.

Marco


-- 
Marco Herrn             herrn at gmx.net
(GnuPG/PGP-signed and crypted mail preferred)
Key ID: 0x94620736




More information about the Python-list mailing list