Movatterモバイル変換
[0]ホーム
PEP 245
Aahz Maruchaahz at panix.com
Thu Apr 12 14:42:17 EDT 2001
In article <3ACDB3A1.9B4E3B5A at projtech.com>,Scott Finnie <scott at projtech.com> wrote:>>Hmmm. A question about PEP245: how do interfaces differ from types?>>Both seem to have the same motivation: to declare not what something is,>but what it can do:>> . "An object's type ... determines the operations that an object> supports (e.g., ``does it have a length?)"> - Python Language reference section 3.1> . "Interfaces try to provide a way for you to ... specify a contractual> obligation for your object"> (PEP245, "The Problem" section).>>There are currently limitations on typing (only covers built-ins, object>can only be of a single type) but neither of these seem justifiable>reasons for introducing a new construct rather than extending the>existing one?What you're talking about here is the type/class split. There have beena lot of suggestions for healing that, but they all require a *lot* ofwork (plus probably breaking a lot of code). Interfaces are in a lot ofways a gimmick for creating type-like functionality for classes.There are some differences, though: Python currently does not have amechanism for specifying the interface for a type. It seems ratherlikely that creating an interface mechanism for classes and thenextending it to types will be the easier and simpler route.-- --- Aahz <*> (Copyright 2001 byaahz at pobox.com)Androgynous poly kinky vanilla queer het Pythonistahttp://www.rahul.net/aahz/Hugs and backrubs -- I break Rule 6Why is this newsgroup different from all other newsgroups?
More information about the Python-listmailing list
[8]ページ先頭