[Python-Dev] PEP 544: Protocols (original) (raw)
Barry Warsaw barry at python.org
Mon Mar 20 19:23:57 EDT 2017
- Previous message (by thread): [Python-Dev] PEP 544: Protocols
- Next message (by thread): [Python-Dev] PEP 544: Protocols
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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 -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 801 bytes Desc: OpenPGP digital signature URL: <http://mail.python.org/pipermail/python-dev/attachments/20170320/c9a2c754/attachment.sig>
- Previous message (by thread): [Python-Dev] PEP 544: Protocols
- Next message (by thread): [Python-Dev] PEP 544: Protocols
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]