On Sat, Oct 30, 2021 at 10:51:42PM -0700, 2qdxy4rzwzuui...@potatochowder.com wrote:
> I still see anything more complicated than a constant or an extremely > simple expression (len(a)? well, ok, maybe; (len(a) if is_prime((len(a)) > else next_larger_prime(len(a)))? don't push it) as no longer being a > default, but something more serious, but I don't have a better name for > it than "computation" or "part of the function" or even "business logic" > or "a bad API." There is no benefit to using an actual constant as a late-bound default. If the value is constant, then why delay evaluation? You're going to get the same constant one way or another. So linters should flag misuse like: func(@arg=0) List and dict displays ("literals") like [] and {} are a different story, but they aren't constants. I agree that extremely complex expressions fall under the category of "Don't Do That". But that's a code review and/or linter problem to solve. Most uses of late-binding defaults are going to be short and simple, such as: * an empty list or dict display; * call a function; * access an attribute of self; * len of another argument. Right now, defaults can be set to arbitrarily complex expressions. When is the last time you saw a default that was uncomfortably complex? -- Steve _______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/CIXFE22RUURSHRAYPBZS4ZOG5FNSWVWS/ Code of Conduct: http://python.org/psf/codeofconduct/