> def _gn(x):
>     return x.upper()
>
> great_name = _gn
>
> class myclass:
>     def mymethod(self, great_name=False):
>         if great_name:
>             return _gn('something')
>         else:
>             return 'something'


>  >>> def great_name(x):
> ...     return x.upper()
> ...
>  >>> class myclass(object):
> ...     def mymethod(self, great_name=False):
> ...         if great_name:
> ...             return globals()['great_name']('something')
> ...         else:
> ...             return 'something'
> ...
>  >>> myclass().mymethod()
> 'something'
>  >>> myclass().mymethod(True)
> 'SOMETHING'



Thanks a lot for both suggestions, they were the things I was looking for.
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to