On Tue, May 17, 2016 at 3:05 PM, Steven D'Aprano <steve+comp.lang.pyt...@pearwood.info> wrote: > Although the instrumentation is used inside the decorator, it is actually part > of the public API for the function. So the user can do this: > > > @decorate > def myfunction(): > ... > > > # later > myfunction.instrument.query() > > and see what data has been collected. > > So it is important that the name of the attribute be a public name.
Sounds to me like a collision is largely not your problem, so I'd go with just tossing in a simple warning as a courtesy. There are plenty of situations where that courtesy wouldn't be given, and the caller would have to cope with the clash, so this would already be one up on that. Not worth going to a heap of hassle to deal with it, as most functions don't grow new attributes at a great rate. A quick check and a warning, and that's plenty. ChrisA -- https://mail.python.org/mailman/listinfo/python-list