Correct Attribute Assignment Methodology?

Tim Cook timothywayne.cook at gmail.com
Tue Jul 29 14:22:46 EDT 2008


Say I have these classes:

class Parent(object):
  """Parent is abstract"""
  a=None
  def showA():
   return self.a

class Child(Parent):
  """inherits a and showA from Parent"""

  def __init__(self,a,b):
    self.a=a   
    self.b=b

  def showAB():
   return self.a,self.b


class GrandChild(Child):
  """inherits all of the above"""

  def __init__(self,a,b,c):
   self.a=a
   self.b=b  
   """should this be Child.__init__(a,b)? or Child.__init__(b)?""  
   """if so; why? if not why not?"""
   self.c=c

Thanks for answering these very basic questions but I am not certain
about the correct way.  I know that in Python, assignment in the
GrandChild class will work but is that correct?

--Tim

 

-- 
**************************************************************************
Join the OSHIP project.  It is the standards based, open source
healthcare application platform in Python.
Home page: https://launchpad.net/oship/ 
Wiki: http://www.openehr.org/wiki/display/dev/Python+developer%27s+page 
**************************************************************************
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 196 bytes
Desc: This is a digitally signed message part
URL: <http://mail.python.org/pipermail/python-list/attachments/20080729/9d87183c/attachment.sig>


More information about the Python-list mailing list