On Tue, Apr 28, 2020 at 5:26 PM ast <ast@invalid> wrote: > > Le 28/04/2020 à 09:13, Chris Angelico a écrit : > > On Tue, Apr 28, 2020 at 4:56 PM ast <ast@invalid> wrote: > >> > >> Le 27/04/2020 à 04:46, Bob van der Poel a écrit : > > > > > > "Best"? Not sure about that. Functions are first-class objects in > > Python, so a function *is* a callable object. You don't have to create > > a custom class with a call method just to be able to attach attributes > > to your function. > > > > ChrisA > > > > Using a mutable object as a function default parameter value > and changing it inside the function looks like a "trick" > according to me.
Sure. But you're contrasting this to a suggestion to literally just attach attributes to a function. Python lets you actually do that. You don't have to simulate the feature by creating a custom class and making it callable - you just straight-up add attributes to a function. Sure, what you suggested works, but there's no reason to. ChrisA -- https://mail.python.org/mailman/listinfo/python-list