2012-06-06 19 views
7

Come ottengo la firma dei metodi incorporati? Esempio:. Dict() ottenere (k)Ottieni la firma del metodo incorporata - Python

>> a = dict().get 
>> a 
<built-in method get of dict object at 0x1003aafd0> 
>> a.__doc__ 
'D.get(k[,d]) -> D[k] if k in D, else d. d defaults to None.' 
>> import inspect 
>> inspect.getargspec(a) 
TypeError: <built-in method get of dict object at 0x100377250> is not a Python function 

Vorrei vedere il risultato come questo

>> a.some_function() 
('key', 'default'=None) 
+0

possibile duplicato di [Come ottenere l'elenco degli argomenti di un costruttore di classi Python integrato?] (Http://stackoverflow.com/questions/7628081/how-to-get-arguments-list-of-a-built -in-python-class-constructor) – ChristopheD

+0

Correlati: http://bugs.python.org/issue1748064 Breve riassunto: non è possibile (in CPython) al momento. – ChristopheD

risposta

4

Non credo che questo è possibile per le funzioni incorporate in pitone che sono implementati in C. Vedere la discussione sull'errore this per ulteriori dettagli.

Problemi correlati