LSP and constructors with first-class classes
s713221 at student.gu.edu.au
Mon Aug 27 12:38:39 CEST 2001
"John J. Lee" wrote:
> I've been thinking about this for a while now, and I still can't see what
> the 'right thing' is.
> I have a class, Fit, that is not intended to be instantiated itself: you
> have to subclass it first. It isn't only an interface, though, it
> implements a lot, too. Quote from docstring:
> Subclasses' __init__ method should call Fit.__init__ with the Scan and
> Data instances as arguments, and then add a Theory subclass as
> self.theory. Everything else is optional...
> The constructor takes two arguments:
> def __init__(self, scan, data):
> scan: must have an attribute 'name'
> data: Data instance
> self.scan, self.data = scan, data
> Data is unproblematic. The 'Scan' is what is puzzling me. It clearly
> shouldn't be there: some Fits shouldn't even *have* a Scan. So I'll get
> rid of it:
> def __init__(self, data):
Not entirely sure what you're trying here, but it was interesting enough
that I've "watch thread"'ed it in netscape messenger to catch the
replies. On your first constructor, would this do?
def __init__(self, data, scan=None):
self.data = data
self.scan = scan
Joal Heagney is: _____ _____
/\ _ __ __ _ | | _ ___ |
/__\|\ || ||__ |\ || |___|/_\|___] |
/ \ \_||__ ||___| \_|! | | \ \ !
More information about the Python-list