On Mon, Sep 1, 2008 at 11:35 AM, Steven D'Aprano <[EMAIL PROTECTED]> wrote: > That's relatively fragile, since such names aren't reserved in any way. > It's easy to fool a name comparison check with an accidental name > collision: > >>>> class function(object): # not a reserved name > ... pass > ... >>>> x = function() >>>> type(x).__name__ > 'function' >>>> x() # must be a function then... > Traceback (most recent call last): > File "<stdin>", line 1, in <module> > TypeError: 'function' object is not callable > > > But not so easy to fool a type check: > >>>> type(x) == new.function > False > > Of course that's not bullet-proof either. I leave it as an exercise to > discover how you might break that piece of code. >
Ok, so... What is the best way to do this? The "most pythonic"? -- -- luca -- http://mail.python.org/mailman/listinfo/python-list