python接口 [英] python interfaces

查看:89
本文介绍了python接口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



可能以前有人问过,但我还是会问。

为什么python不通过标准库提供接口?或者它是否曾建议将b $ b包括在语言中?

Zope的实现看起来非常灵活和简单。


谢谢。

Hi,
Probably it has been asked before, but I''ll still ask.
Why doesn''t python provide interfaces trough its standard library? Or it
was ever proposed to be included in the language?
Zope''s implementation seems pretty flexible and straightforward.

Thanks.

推荐答案

1月4日下午3:59,hyperboreean< hyperbore ... @ nerdshack.comwrote:
On Jan 4, 3:59 pm, hyperboreean <hyperbore...@nerdshack.comwrote:



可能之前有人问过,但我还是会问。

为什么没有'python通过其标准库提供接口吗?或者它是否曾建议将b $ b包括在语言中?

Zope的实现看起来非常灵活和简单。

$ b $谢谢。
Hi,
Probably it has been asked before, but I''ll still ask.
Why doesn''t python provide interfaces trough its standard library? Or it
was ever proposed to be included in the language?
Zope''s implementation seems pretty flexible and straightforward.

Thanks.



Python 3.0将引入抽象基类:

http://www.python.org/dev/peps/pep-3119/

hyperboreean< hy ********** @ nerdshack.comwrote:
hyperboreean <hy**********@nerdshack.comwrote:

>为什么python不提供接口槽它的标准库?
>Why doesn''t python provide interfaces trough its standard library?



因为他们没有意义。 Java接口是对多重继承的复杂性的一种破解。 Python做多个

继承Just Fine(给予或采取super()的微妙之处)所以

不需要它们。


纯粹使用类型安全概念的接口为增加的混乱和不便提供了宝贵的小收益。

将它们与Java的明确声明要求进行比较

方法签名中抛出的异常,如果你愿意的话。


-

\S - si *** @ chiark.greenend.org.uk - http://www.chaos.org.uk/~sion/

坦白说我没有感情以某种方式向企鹅投掷

- 亚瑟C.克拉克

她的努力是什么?ddre hl?heddes b?ce bump bump bump >

Because they''re pointless. Java interfaces are a hack around the
complexities of multiple inheritence. Python does multiple
inheritence Just Fine (give or take the subtleties of super()) so
does not need them.

Interfaces used purely with the idea of type safety provide
precious little gain for the added clutter and inconvenience.
Compare them to Java''s requirement for explicit declaration of
exceptions thrown in a method signature, if you will.

--
\S -- si***@chiark.greenend.org.uk -- http://www.chaos.org.uk/~sion/
"Frankly I have no feelings towards penguins one way or the other"
-- Arthur C. Clarke
her nu becomet se bera eadward ofdun hl?ddre heafdes b?ce bump bump bump


Sion Arrowsmith写道:
Sion Arrowsmith wrote:

hyperboreean< hy ********** @ ner dshack.comwrote:
hyperboreean <hy**********@nerdshack.comwrote:

>为什么python不通过标准库提供接口?
>Why doesn''t python provide interfaces trough its standard library?



因为他们没有意义。


Because they''re pointless.



错误。我正在使用Eclipse与Java开发工具(JDT)一起工作

a使用接口执行大量检查,警告

和代码生成*几乎真实我编辑代码时的时间*。

因为JDT知道接口它知道该做什么和建议。

接口是一个软件规范,允许您使用软件

包而无需进行大量代码研究。这是一件好事。

Wrong. I''m using Eclipse with the Java Development Tools (JDT) who do
a wonderful job using interfaces to perform lots of checking, warning
and code generation *nearly in real time while I am editing my code*.
Because JDT knows interfaces it knows what to do and to suggest. An
interface is a software specification allowing you to use a software
package without extensive code studies. This is a good thing.


Java接口是对多个

继承的复杂性的一种破解。
Java interfaces are a hack around the complexities of multiple
inheritence.



hack是随后用于解决软件问题的东西,而

避免了大的变化。 Java接口源于谨慎的语言

设计。您可以自由地不喜欢Java接口,但称它们为黑客是

只是完全错误。


一旦软件成为非常大的接口对于处理它非常有用/>
复杂性。有没有想过Zope人为什么在他们的Python代码中引入接口?

A hack is something applied subsequently to solve a software problem while
avoiding large changes. Java interfaces originate from careful language
design. You are free to dislike Java interfaces but calling them a hack is
just plain wrong.

Once software becomes really big interfaces are very useful to handle
complexity. Ever wondered why the Zope people introduced interfaces in
their Python code?


接口纯粹用于类型安全提供

因为增加的杂乱和不便而获得的宝贵收益。
Interfaces used purely with the idea of type safety provide
precious little gain for the added clutter and inconvenience.



界面是一个软件规范,允许您使用软件

包而无需进行大量的代码研究。这是一件好事。接口

与多重继承无关。他们只是告诉你如何连接,如何插入。


-

问候/ Gruesse,

Peter Maas,Aachen

电子邮件''cGV0ZXIubWFhc0B1dGlsb2cuZGU = \ n''。decode(''base64'')

An interface is a software specification allowing you to use a software
package without extensive code studies. This is a good thing. Interfaces
have nothing to do with multiple inheritance. They just tell you how to
connect, how to plug in.

--
Regards/Gruesse,

Peter Maas, Aachen
E-mail ''cGV0ZXIubWFhc0B1dGlsb2cuZGU=\n''.decode(''base64'')


这篇关于python接口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆