Abstract Classes
Tim Cook
timothywayne.cook at gmail.com
Sat May 23 07:02:00 EDT 2009
I am implementing a set of specifications that were designed to be OO
language neutral.
Several classes are specified as being abstract; so therefore there
should be no instances of them, correct?
However in the classes that are subclasses what is the correct way in
Python to implement them?
I am using the zope.interface module as well.
For example:
class IA(Interface):
m = Int()
p = TextLine()
class IB(Interface):
x = Bool()
s = Text()
class A(object):
""" This is an abstract class with attributes m is an int and p is a
string"""
implements(IA)
pass
class B(A):
implements(IB)
def __init__(self,m,p,x,s):
m=m
p=p
x=x
s=s
or should it be like:
class A(object):
""" This is an abstract class with attributes m is an int and p is a
string"""
implements(IA)
def __init__(self,m,p):
m=m
p=p
class B(A):
implements(IB)
def __init__(self,m,p,x,s):
A.__init__(m,p)
x=x
s=s
or maybe even:
class B(A):
implements(IB)
def __init__(self,m,p,x,s):
super(A.__init__(m,p))
x=x
s=s
Thanks for any pointers.
Tim
--
Timothy Cook, MSc
Health Informatics Research & Development Services
LinkedIn Profile:http://www.linkedin.com/in/timothywaynecook
Skype ID == timothy.cook
**************************************************************
*You may get my Public GPG key from popular keyservers or *
*from this link http://timothywayne.cook.googlepages.com/home*
**************************************************************
More information about the Python-list
mailing list