Giovanni Porcari wrote:
dict( [ (m,getattr(myInstanceOrClass,m))for m in dir(myInstanceOrClass) if 
callable(getattr(myInstanceOrClass,m))])

Puoi togliere le parentesi quadre (direi Python > 2.4; non ho un 2.4 per provare).

Piu' rapido ancora usare direttamente vars sull'oggetto classe.
Ho messo dict, perche' su quel python ritorna un dictproxy e mi era scomodo da stampare ;)

dict(vars(str))
Out[8]:
{'__add__': <slot wrapper '__add__' of 'str' objects>,
...
 '__getitem__': <slot wrapper '__getitem__' of 'str' objects>,
 '__getnewargs__': <method '__getnewargs__' of 'str' objects>,
...
 '_formatter_parser': <method '_formatter_parser' of 'str' objects>,
 'capitalize': <method 'capitalize' of 'str' objects>,
 'center': <method 'center' of 'str' objects>,
 'count': <method 'count' of 'str' objects>,
...
 'lower': <method 'lower' of 'str' objects>,
 'lstrip': <method 'lstrip' of 'str' objects>,
 'partition': <method 'partition' of 'str' objects>,
...
 'upper': <method 'upper' of 'str' objects>,
 'zfill': <method 'zfill' of 'str' objects>}


--
.
..: -enrico-

_______________________________________________
Python mailing list
Python@lists.python.it
http://lists.python.it/mailman/listinfo/python

Rispondere a