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

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -