>> The only precedent that jumps out for me is itertools.chain() and
itertools.chain.from_iterable(). It's quite likely that something
>> I don't use much has used the same pattern though.

I think David is right: itertools.chain.from_iterable() is the only
> place I know of with an attribute on a function that's another function.
> Alternate constructors are generally classmethods. Not that the
> distinction is terribly important, but it is a distinction, and it's
> documented differently.
>

I don't think being a function versus a classmethod is important here.
Just that the underlying name is *callable*.

If the implementation was like this dumb example, it wouldn't matter that
it was a class instance (e.g. for a hypothetical `greet` builtin)

>>> class Greeting:
...     def __call__(self, name):
...         print("Hello", name)
...     def twice(self, name):
...         print(f"Hi {name}, howdy there!")
...
>>> greet = Greeting()
>>> greet('Eric')
Hello Eric
>>> greet.twice('Eric')
Hi Eric, howdy there!



-- 
The dead increasingly dominate and strangle both the living and the
not-yet born.  Vampiric capital and undead corporate persons abuse
the lives and control the thoughts of homo faber. Ideas, once born,
become abortifacients against new conceptions.
_______________________________________________
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/NHOACKGCAUDJEOEC23G7E2IKL2LSKOHZ/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to