I now have a class called A.
I have code like this.
from my.package.location.A import A ... foo = A.doSomething(bar)
It's great.
But now I have a new version of A named A, but in a different package, but I want to use only this different A in a specific scenario. So I can do something like this:
if(OldVersion): from my.package.location.A import A else: from new.package.location.A import A ... foo = A.doSomething(bar)
It works great. But it is ugly. How can I do it better? I really want to do something like this
from my.abstraction.layer.AFactory import AFactory ... myA = AFactory.giveMeA()
Is there any way to make this easier? Without a factory layer? Now it can turn any call of a static method into my class in 2 lines. I can always hold the link in the class to reduce the impact, but I really hope that python will have a simpler solution.
asdasdasd
source share