problem with str()

Paul Rubin http
Thu Mar 15 19:34:48 EDT 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