python - Issue with Class Inheritance -
i'm trying create class extends httpbasicauthhandler. reason same approach use in older code not working here.
class authinfo(urllib2.httpbasicauthhandler): def __init__(self, realm, url, username, password): self.pwdmgr = urllib2.httppasswordmgrwithdefaultrealm() self.pwdmgr.add_password(none, url, username, password) super(authinfo, self).__init__(self.pwdmgr)
here error:
traceback (most recent call last): file "./restresult.py", line 67, in ? auth = authinfo(none, "default", "xxxxx", "xxxxxxxx") file "./restresult.py", line 47, in __init__ super(authinfo, self).__init__(self.pwdmgr) typeerror: super() argument 1 must type, not classobj
the urllib2.httpbasicauthhandler
class old-style class (it doesn't inherit object
), means can't used super
. have call __init__
directly instead:
urllib2.httpbasicauthhandler.__init__(self, self.pwdmgr)
Comments
Post a Comment