
Hi Luc,
Actually it almost works, because Refinery should not inherit
from normal_eqns.non_linear_ls, only the adapter, AdaptLstbx. So I can do:
import abc
from scitbx.lstbx import normal_eqns
class Refinery(object):
__metaclass__ = abc.ABCMeta
pass
class AdaptLstbx(Refinery, normal_eqns.non_linear_ls):
class __metaclass__(normal_eqns.non_linear_ls.__class__, abc.ABCMeta):
pass
pass
This successfully stops Refinery being constructed. However, you do point
out the critical flaw, which is that AdaptLstbx can now be constructed, yet
this still lacks the missing 'run' method, which would be supplied another
child. Now the original raise NotImplementedError() seems like the clearest
solution. I suppose this is why people on the internet argue that abc isn't
pythonic.
Cheers
-- David
On 9 January 2014 00:48, Luc Bourhis
import abc from scitbx.lstbx import normal_eqns class Refinery(object): class __metaclass__(normal_eqns.non_linear_ls.__class__, abc.ABCMeta): pass
class AdaptLstbx(Refinery, normal_eqns.non_linear_ls): pass
Except that it does not prevent r = Refinery() after all since the __metaclass__ has a valid instantiation through normal_eqns.non_linear_ls.__class__.
which gives me a flashback: I've already burnt myself with that!
Luc
_______________________________________________ cctbxbb mailing list [email protected] http://phenix-online.org/mailman/listinfo/cctbxbb