473,320 Members | 1,979 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Interface support?

Is it possible to design interfaces that classes must implement in
Python? If it's not, is this functionality planned at all for the future?

Thanks,
Steve
Jul 18 '05 #1
5 1364
Twisted and Zope already use interfaces. You can download
the interface package and use it in you project.
Michele Simionato

Jul 18 '05 #2
Michele Simionato wrote:
Twisted and Zope already use interfaces. You can download
the interface package and use it in you project.


Thanks for the response. I'm completely new to Python, where exactly
would I go to find these interface packages(Python site, or Twisted/Zope
sites)? Is it the same interface package for both, or are they
different? If different, is one better than the other?

Thanks,
Steve
Jul 18 '05 #3
Now they use the same interface package. For the other
questions: google is your friend. (try "zope interfaces"
then "twisted interfaces").

Jul 18 '05 #4
Steve wrote:
Is it possible to design interfaces that classes must implement in
Python?
There are some well-known 'independent' implementations of interfaces:
Zope Interfaces :http://www.zope.org/Wikis/Interfaces/FrontPage
- a separable component of the much larger app server
Twisted Interfaces: see http://twistedmatrix.com/

PyProtocols: http://peak.telecommunity.com/PyProtocols.html, whose
author is one of the protagonists in the PEP246 saga
There are also several possible light-weight roll-your-own solutions
One common idiom is an abstract base class:

class SomeInterface(object):
def someMethod(self, argspec):
# Should never get here, because the implementation overrides this method
raise NotImplmentedError

but the compiler doesn't pay any special attention to these classes so failure
to implement the interface is detected at runtime

If it's not, is this functionality planned at all for the future?

Python Enhancement Proposals 245, and 246 http://www.python.org/peps/ discuss an
interface syntax and the related topic of object adaptation. These are both
current discussions among the Python developers with no decision on whether/when
to introduce either as far as I know. Observer the fray at:
http://mail.python.org/pipermail/python-dev/
Guido Van Rossum (Python creator and BDFL) recently blogged about "Optional
Static Type Checking" http://www.artima.com/weblogs/viewpost.jsp?thread=89161
as part of long-range planning for a future Python 3000 (some years in the future)

HTH

Michael

Jul 18 '05 #5
>>>>> "Michael" == Michael Spencer <ma**@telcopartners.com> writes:

Michael> Steve wrote:
Is it possible to design interfaces that classes must implement
in Python?


Michael> PyProtocols: http://peak.telecommunity.com/PyProtocols.html,

This (PyProtocols) seems to be the one with biggest momentum at the
time being, so if you can't be bothered to perform an independent and
balanced evaluation, go for PyProtocols :-).

--
Ville Vainio http://tinyurl.com/2prnb
Jul 18 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Phillip J. Eby | last post by:
PEP: 333 Title: Python Web Server Gateway Interface v1.0 Version: $Revision: 1.1 $ Last-Modified: $Date: 2004/08/27 17:30:09 $ Author: Phillip J. Eby <pje at telecommunity.com> Discussions-To:...
4
by: Roy Pereira | last post by:
I have an application that is composed of a set of "Content" dlls and a viewer application. The viewer calls a standard set of functions that are present in all the dlls. I maintain this by...
9
by: Anon Email | last post by:
Hi people, I'm learning about header files in C++. The following is code from Bartosz Milewski: // Code const int maxStack = 16; class IStack
6
by: Wolfgang Keller | last post by:
Hello, I'm looking for a spreadsheet application (MacOS X prefered, but Windows, Linux ar available as well) with support for Python scripting (third-party "plug-ins" are ok) and a database...
0
by: Nadav | last post by:
Hi, Introduction: **************** I have a collection of COM objects that support a constant interface, the interface is build of a collection of properties, methods and events ( events are...
4
by: Doug | last post by:
I am working on an existing .NET (C Sharp) component that had a com interface that was used by a VB component. When it was originally written, it had the SSEAssemblyCom class below - minus the two...
4
by: Ray Dukes | last post by:
What I am looking to do is map the implementation of interface properties and functions to an inherited method of the base class. Please see below. ...
5
by: LS | last post by:
Can a WebMethod return an Interface type? Can we pass an interface parameter ? Example : public interface IEntity { long Id { get; set; } string Name { get; set; } }
8
by: Gregory | last post by:
I have a question about using STL containers in C++ class public interface. Lets say that I want to return some container from class method or accept class method parameter as some container. For...
0
by: YellowFin Announcements | last post by:
Introduction Usability and relevance have been identified as the major factors preventing mass adoption of Business Intelligence applications. What we have today are traditional BI tools that...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.