problem with str()

Paul Rubin http
Fri Mar 16 00:34:48 CET 2007


kyosohma at gmail.com writes:
> methodList = [str for str in names if callable(getattr(obj, str))]
> 
> instead, do something like this:
> 
> methodList = [i for i in names if callable(getattr(obj, i))]

or:

   methodList = list(str for str in names if callable(getattr(obj, str)))

genexps, unlike listcomps, make a new scope for their index variable.



More information about the Python-list mailing list