Class optimization at runtime
Jeff Shannon
jeff at ccvcorp.com
Tue Aug 3 16:32:59 EDT 2004
Dan Sommers wrote:
>Alternatively:
>
> module WithOption:
> class Foo:
> # whatever
> class Bar:
> # whatever
>
> module WithOutOption:
> class Foo:
> # whatever
> class Bar:
> # whatever
>
> if option:
> from WithOption import *
> else:
> from WithoutOption import *
>
> x = Foo( )
>
>
Or even better:
if option:
import WithOption as FooModule
else:
import WithoutOption as FooModule
x = FooModule.Foo( )
(I twitch every time I see 'from X import *' ...)
Jeff Shannon
Technician/Programmer
Credit International
More information about the Python-list
mailing list