Re: [Python-Dev] PEP 544: Protocols

2017年3月20日 16:26:42 -0700

On Mar 20, 2017, at 01:00 PM, Ivan Levkivskyi wrote:
> from zope.interface import Interface, Attribute, implements
>
> class IEmployee(Interface):
>
> name = Attribute("Name of employee")
>
> def do(work):
> """Do some work"""
>
> class Employee(object):
> implements(IEmployee)
IIUC, the Python 3 way to spell this is with a decorator.
from zope.interface import implementer
@implementer(IEmployee)
class Employee:
(also, since this is Python 3, do you really need to inherit from object?)
Cheers,
-Barry

Attachment: pgpieJvP53ib2.pgp
Description: OpenPGP digital signature

_______________________________________________
Python-Dev mailing list
[email protected]
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to