यह थोड़ा मुश्किल इस व्यवहार को समझने के लिए किया जाता है:पायथन में, एक वस्तु कार्य करता है?
def a():
pass
type(a)
>> function
तो a
की type
function
है, function
की type
क्या है?
type(function)
>> NameError: name 'function' is not defined
और क्यों a
से type
की type
type
है करता है?
type(type(a))
>> type
अंतिम एक: यदि a
एक object
है, कारण है कि मैं ऐसा नहीं कर सकते:
isinstance(a, object)
>> True
class x(a):
pass
TypeError: Error when calling the metaclass bases
function() argument 1 must be code, not str
धन्यवाद!
वे सभी सही लगते हैं। आप 'प्रकार (फ़ंक्शन)' वापस आने की अपेक्षा करते हैं? – CoryKramer
संभावित डुप्लिकेट ["प्रथम श्रेणी" ऑब्जेक्ट्स क्या हैं?] (Http://stackoverflow.com/questions/245192/what-are-first-class-objects) –
संभव डुप्लिकेट [पायथन में मेटाक्लासस क्या है?] (http://stackoverflow.com/questions/100003/what-is-a-metaclass-in-python) – davidism