On 04/27/2020 08:26 AM, Barry wrote:
On 27 Apr 2020, at 16:01, Ethan Furman wrote:
I'm objecting to using "beginners" as the basis for name choices for advanced topics.
Aside from that, `once` is a fine name. I'm sure it means that a function can only be defined once, and subsequent definitions will either be ignored or raise, right?
>>> @once ... def my_unique_function(...): ... do_something_cool() ... >>> def something_else(): ... pass ... >>> def my_unique_function(...): ... # uh oh, duplicate! ... RuntimeError - duplicate function name detected
That needs a linter to spot I think.
Indeed. Linters are great things, although it took me awhile to really appreciate them.
Or are you saying that once could be interpreted to mean I cannot do that 2nd def?
That is what I was saying -- that `once`, all by itself, could mean multiple things. Although, really, what I am saying is that for a beginner to have the thought, "This function always returns the same result, but I can't call it immediately -- I wish there was a way to have it run once and then always return that first result," and go from there to caches and decorators stretches the bounds of credulity past the breaking point. Perhaps we have different meanings for "beginners". -- ~Ethan~