Python Classes: Old-style vs New-style

I ran into a bit of a problem, trying to use the new-style class syntax while calling a class that apparently only supports the old-class style syntax (thanks due to Brend on #python at for pointing that out). Look closely at the call to super() in the following code:

# -*- set tabstop=4 -*-

import cgi

class CGIWrapper(cgi.FieldStorage):
    def __init__(self):
        super(CGIWrapper, self).__init__()

if __name__ == "__main__":
    c = CGIWrapper()

Traceback (most recent call last):
 File "", line 17, in ?
  c = CGIWrapper()
 File "", line 9, in __init__
  super(CGIWrapper, self).__init__()
TypeError: super() argument 1 must be type, not classobj

The workaround, naturally, is to call cgi.FieldStorage using the old-class style way.

class CGIWrapper(cgi.FieldStorage):
    def __init__(self):


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s