[Python-ideas] Class autoload

Rob Cliffe rob.cliffe at btinternet.com
Sat Mar 3 13:44:20 EST 2018



On 03/03/2018 17:38, Eric V. Smith wrote:
>
> I'd just do:
>     import yourmodule
>     obj = yourmodule.YourClass()
>
> Or as one line, if that's your thing:
>     import yourmodule; obj = yourmodule.YourClass()
Which is
     More transparent: it's evident what the imported module is used for.
     More maintainable: you only need to add or remove one line or two 
adjacent lines per instance, instead of two widely separated lines.
(as long as you're happy to defer the imports, of course).
Regards
Rob Cliffe


More information about the Python-ideas mailing list