2012-09-26 24 views

回答

4

爲Python 2.x的:

[name for name, method in Class.__dict__.iteritems() if callable(method)] 

爲Python 3.x的:

[name for name, method in Class.__dict__.items() if hasattr(method,'__call__')] 
+0

這在我看來,'inspect'應該有一些要做到這一點更好一點......(但我不知道 - 我沒有看過) – mgilson

+0

工作正常。謝謝。 – Ben

相關問題