How to instatiate a class of which the name is only known at runtime?

John Roth newsgroups at jhrothjr.com
Tue Sep 9 18:40:11 EDT 2003


"Erik Max Francis" <max at alcyone.com> wrote in message
news:3F5E3E3E.9C31763F at alcyone.com...
> John Roth wrote:
>
> > As Nick said, you can use the exec statement. You can
> > also use the _import() function.
>
> >>> _import
> Traceback (most recent call last):
>   File "<stdin>", line 1, in ?
> NameError: name '_import' is not defined
>
> Do you mean __import__?

Yes.

John Roth
>
> -- 
>    Erik Max Francis && max at alcyone.com && http://www.alcyone.com/max/
>  __ San Jose, CA, USA && 37 20 N 121 53 W && &tSftDotIotE
> /  \ But when I reached the finished line / Young black male
> \__/  Ice Cube






More information about the Python-list mailing list