Correct to use instance = module.__dict__[class_name]() ?
Andy Gimblett
gimbo at ftech.net
Tue Mar 19 04:32:41 EST 2002
On Mon, Mar 18, 2002 at 07:48:42PM +0100, Just van Rossum wrote:
> This would be better:
>
> def bar(module_name, class_name):
> module = __import__(module_name, globals(), locals(), [])
> handler = getattr(module, class_name)()
> return handler
Ah, yes. That feels nicer. :-) Excellent - thanks!
-Andy
--
Andy Gimblett - Programmer - Frontier Internet Services Limited
Tel: 029 20 820 044 Fax: 029 20 820 035 http://www.frontier.net.uk/
Statements made are at all times subject to Frontier's Terms and
Conditions of Business, which are available upon request.
More information about the Python-list
mailing list