super() での疑問

                  • -

解決 :mechanize.Browser が object を継承しない古いタイプのクラスだったみたい

                  • -

これは OK

>>> class Foo(object):
    def __init__(self,text):
        super(Foo,self).__init__(self)
... 
>>> foo = Foo('test')


で、mechanize.Browser 継承して親のコンストラクタ呼ぼうとしたら

>>> import mechanize
>>> class MyBrowser(mechanize.Browser):
...     def __init__(self,userid,passwd):
...         super(MyBrowser,self).__init__(self)
... 
>>> foo = MyBrowser('test','test')
------------------------------------------------------------
Traceback (most recent call last):
  File "<ipython console>", line 1, in <module>
  File "<ipython console>", line 3, in __init__
TypeError: super() argument 1 must be type, not classobj

なんで!?!?
教えてエロい人!!!

...         super(MyBrowser,self).__init__(self)

...         mechanize.Browser.__init__(self)

にすれば動くんだけど、なんかキモイなぁ><