On Thu, Feb 10, 2022 at 2:15 PM Ethan Furman <et...@stoneleaf.us> wrote:

> On 2/10/22 1:45 PM, Brett Cannon wrote:
>
>  > Protocols would let folks rely on a common Path object API w/o having
> to require the object
>  > come from pathlib itself or explicitly subclass something (which I
> admit would be rare, but
>  > there's no reason to artificially constrain this either). Now maybe
> this is too broad of an
>  > API for people to care, but since protocols are also ABCs it doesn't
> inherently make things
>  > worse, either. So I would say subclassing Protocol makes sense while
> still using
>  > abc.abstractmethod for methods people must implement.
>
> Brett, when you say Protocol are you referring to static typing?


Yep, specifically
https://docs.python.org/3/library/typing.html#typing.Protocol .


>   In your earlier email I thought you were referring to
> building blocks such as _fs_path, or the __iter__ and __next__ protocols.
>

Technically those are *special methods*  that define a protocol (obviously
`typing.Protocol` got its name from somewhere 😉). But it's all the same
concept: defining what methods you expect an object to have.
_______________________________________________
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-le...@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/python-dev@python.org/message/IGYMVZYNQZZ2PXBQTOIG7TVJVZWFNLYI/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to