<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
  <title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
<br>
<blockquote cite="mid:mailman.48.1266722371.4576.tutor@python.org"
 type="cite">
  <blockquote type="cite">
    <pre wrap="">Hi,

I am having trouble understanding how superclass calls work.  Here's
some code...
    </pre>
  </blockquote>
  <pre wrap=""><!---->
What version of Python are you using?

In Python 2.x, you MUST inherit from object to use super, and you MUST 
explicitly pass the class and self:

class ParentClass(object):
    def __init__(self, a, b, c):
        do something here

class ChildClass(ParentClass):
    def __init__(self, a, b, c):
        super(ChildClass, self).__init__(a, b, c)

In Python 3.x, all classes inherit from object and you no longer need to 
explicitly say so, and super becomes a bit smarter about where it is 
called from:

# Python 3 only
class ParentClass:
    def __init__(self, a, b, c):
        do something here

class ChildClass(ParentClass):
    def __init__(self, a, b, c):
        super().__init__(a, b, c)


I assume you are using Python 3.0 or 3.1. (If you're 3.0, you should 
upgrade to 3.1: 3.0 is s-l-o-w and no longer supported.)


Your mistake was to pass self as an explicit argument to __init__. This 
is not needed, because Python methods automatically get passed self:

  </pre>
  <blockquote type="cite">
    <pre wrap="">    def __init__(self):
        super().__init__(self)
    </pre>
  </blockquote>
  <pre wrap=""><!---->
That has the effect of passing self *twice*, when __init__ expects to 
get self *once*, hence the error message you see:

  </pre>
  <blockquote type="cite">
    <pre wrap="">When the super().__init__ line runs I get the error "__init__() takes
exactly 1 positional argument (2 given)"
    </pre>
  </blockquote>
</blockquote>
Hi Steven, thanks for the reply.<br>
<br>
Fortunately I am using Python 3.1, so I can use the super().__init__(a,
b, c) syntax.<br>
<br>
Regards,<br>
Alan<br>
</body>
</html>