मुझे कुछ त्रुटि मिलती है जिसे मैं समझ नहीं सकता। कोई भी संकेत मेरे नमूना कोड के साथ क्या गलत है?सुपर() त्रुटि के साथ विफल रहता है: TypeError "तर्क 1 टाइप होना चाहिए, classobj नहीं"
class B:
def meth(self, arg):
print arg
class C(B):
def meth(self, arg):
super(C, self).meth(arg)
print C().meth(1)
मुझे 'सुपर' अंतर्निहित विधि की सहायता से नमूना परीक्षण कोड मिला। वर्ग 'सी'
यहाँ त्रुटि है:
Traceback (most recent call last):
File "./test.py", line 10, in ?
print C().meth(1)
File "./test.py", line 8, in meth
super(C, self).meth(arg)
TypeError: super() argument 1 must be type, not classobj
FYI करें, यहाँ मदद (सुपर) अजगर से ही है:
Help on class super in module __builtin__:
class super(object)
| super(type) -> unbound super object
| super(type, obj) -> bound super object; requires isinstance(obj, type)
| super(type, type2) -> bound super object; requires issubclass(type2, type)
| Typical use to call a cooperative superclass method:
| class C(B):
| def meth(self, arg):
| super(C, self).meth(arg)
|
[पाइथन सुपर() के संभावित डुप्लिकेट TypeError उठाता है! क्यों?] (Http://stackoverflow.com/questions/489269/python-super-raises-typeerror- क्यों) – user
मेथ ?? क्या यह एक प्रोग्रामिंग शब्द है, या ... पता है? कृपया स्पष्ट करें। – Cplusplusplus
@Cplusplusplus: शायद विधि के लिए खड़ा है ;-) – ShadowFlame