namespace issue

Steven D'Aprano steve at REMOVETHIScyber.com.au
Thu Apr 13 22:59:02 EDT 2006


On Thu, 13 Apr 2006 22:59:52 +0200, Daniel Nogradi wrote:

> I would like to give the same name to a keyword argument of a class
> method as the name of a function, with the function and the class
> living in the same namespace and the class method using the
> aforementioned function. 

That's a problem right there. As soon as you find yourself needing to
distinguish between "great_name the function" and "great_name the
argument", you have a potential source of API confusion, no matter how
great the name is.

But if you absolutely must:

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'




-- 
Steven.




More information about the Python-list mailing list