On 2021-11-12 at 14:43:07 +1100, Steven D'Aprano <[email protected]> wrote:
> On Thu, Nov 11, 2021 at 10:06:45PM -0500, Ricky Teachey wrote: > > > Is there a standard idiom-- perhaps using a type-hint-- to signal to the > > IDE/linter that my user-defined class is intended to be used as a > > function/factory, and not as a type (even though it is in fact a type)? > > Not really. I don't think there is even a standard idiom for the human > reader to decide whether something is used as a "function" or a "class". > It is subjective, based on usage and convention. As others have pointed > out, many functions in Python can be considered as class constructor: Isn't that why we like duck typing? I don't care what something is, I just care what it does. So when I call zip(x, y) and get an iterable, what's the difference (to me, as the user) whether zip is a class or a function or some arbitraru callable, let alone what the implementation of the resulting iterable is? If I want Java, I know where to find it. _______________________________________________ Python-ideas mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/[email protected]/message/SLYABYDVTYDVY3WNEMAUKPCM6NRU7QNZ/ Code of Conduct: http://python.org/psf/codeofconduct/
