On Thu, Dec 2, 2021 at 8:50 AM Barry Scott email@example.com wrote:
On 1 Dec 2021, at 17:59, Chris Angelico firstname.lastname@example.org wrote:
On Thu, Dec 2, 2021 at 4:40 AM Barry Scott email@example.com wrote:
On 1 Dec 2021, at 06:16, Chris Angelico firstname.lastname@example.org wrote: 3) If "yes" to question 1, would you use it for any/all of (a) mutable defaults, (b) referencing things that might have changed, (c) referencing other arguments, (d) something else?
yes (a) What does (b) mean? example please. yes (c)
global_default = 500 def do_thing(timeout=>global_default): ...
If the global_default timeout changes between function definition and call, omitting timeout will use the updated global.
Similarly, you could say "file=>sys.stdout" and if code elsewhere changes sys.stdout, you'll use that.
On a case-by-case basis I might still put defaulting into the body of the function if that made the intent clearer.
I could see me using @file=sys.stdout.
That's a simplified version, but you might have the same default shown as get_default_timeout() or Defaults.timeout or something like that. The point is that it might be a simple integer, but it could change at any time, and the default should always be "whatever this name refers to".
In any case, it's just one of many use-cases. I was curious what people would use and what they wouldn't.