473,809 Members | 2,575 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Interfaces.

Hi,

Does anyone know what the state of progress with interfaces for python
(last I can see is http://www.python.org/dev/peps/pep-0245/)

I would argue that interfaces/(similar feature) are necessary in any
modern language because they provide a way of separating the
specification from the implementation of a module.

I also had a new idea - when specifying the functionality of a module,
it would be nice to combine examples of valid behaviour / some sort of
testing.

It might therefore be possible to combine unit testing with
interfaces.

What do you all think?

Peter
(new to python so be nice :)
Nov 16 '07 #1
8 1493
On Nov 15, 8:55 pm, "PeterBrad...@g ooglemail.com"
<PeterBrad...@g ooglemail.comwr ote:
Hi,

Does anyone know what the state of progress with interfaces for python
(last I can see ishttp://www.python.org/dev/peps/pep-0245/)

I would argue that interfaces/(similar feature) are necessary in any
modern language because they provide a way of separating the
specification from the implementation of a module.

I also had a new idea - when specifying the functionality of a module,
it would be nice to combine examples of valid behaviour / some sort of
testing.

It might therefore be possible to combine unit testing with
interfaces.

What do you all think?

Peter
(new to python so be nice :)
Status: Rejected

If you really want an "interface" , make a class with methods that
raise NotImplementedE rror.
Nov 16 '07 #2
En Thu, 15 Nov 2007 22:55:13 -0300, Pe**********@go oglemail.com
<Pe**********@g ooglemail.comes cribió:
Does anyone know what the state of progress with interfaces for python
(last I can see is http://www.python.org/dev/peps/pep-0245/)
You may be interested in PEP3119 <http://www.python.org/dev/peps/pep-3119/>

--
Gabriel Genellina

Nov 16 '07 #3
On Nov 16, 1:55 am, "PeterBrad...@g ooglemail.com"
<PeterBrad...@g ooglemail.comwr ote:
Hi,
...
I also had a new idea - when specifying the functionality of a module,
it would be nice to combine examples of valid behaviour / some sort of
testing.
...
Try the 'Pythonic' doctest module:
http://en.wikipedia.org/wiki/Doctest
(new to python so be nice :)
Welcome to Python!

- Paddy.
Nov 16 '07 #4
On Nov 15, 7:55 pm, "PeterBrad...@g ooglemail.com"
<PeterBrad...@g ooglemail.comwr ote:
Hi,

Does anyone know what the state of progress with interfaces for python
(last I can see ishttp://www.python.org/dev/peps/pep-0245/)

I would argue that interfaces/(similar feature) are necessary in any
modern language because they provide a way of separating the
specification from the implementation of a module.

I also had a new idea - when specifying the functionality of a module,
it would be nice to combine examples of valid behaviour / some sort of
testing.

It might therefore be possible to combine unit testing with
interfaces.

What do you all think?
Python is has duck typing. "If it quacks like a duke, it's duck." That
means that you look for what an object can do and has not what it is.
hasattr and getattr are used more than isinstance.
>
Peter
(new to python so be nice :)
Nov 17 '07 #5
On Nov 15, 8:55 pm, "PeterBrad...@g ooglemail.com"
<PeterBrad...@g ooglemail.comwr ote:
Does anyone know what the state of progress with interfaces for python
(last I can see ishttp://www.python.org/dev/peps/pep-0245/)
No progress AFAIK for Python 2.x but Abstract Base Classes (ABCs) are
pretty close to interfaces and have been accepted for Python 3 (http://
www.python.org/dev/peps/pep-3119/). Personally I don't see any
tangible benefit in having "pure" interfaces in additon to ABCs.

George
Nov 17 '07 #6
Benjamin wrote:
Python is has duck typing. "If it quacks like a duke, it's duck."
How do dukes quack, exactly? :)

Regards,
Björn

--
BOFH excuse #290:

The CPU has shifted, and become decentralized.

Nov 17 '07 #7
Pe**********@go oglemail.com wrote:
I would argue that interfaces/(similar feature) are necessary in
any modern language
I wouldn't, but have a look at the Zope interfaces module. It seems
to work similar to Java's interfaces.

Regards,
Björn

--
BOFH excuse #104:

backup tape overwritten with copy of system manager's favourite CD

Nov 17 '07 #8
Bjoern Schliessmann <us************ **************@ spamgourmet.com wrote:
Benjamin wrote:
>Python is has duck typing. "If it quacks like a duke, it's duck."

How do dukes quack, exactly? :)

Regards,
They quack with a North-eastern Scottish accent of course.

The following excerpt from "Scots: Practical Approaches" should make it
clear:
A. From Scotland the What?, by Buff Hardie, Stephen Robertson and
George Donald (Gordon Wright, 1987)

In this comic monologue from 1982, the owner of a toy shop in
Ballater, near Aberdeen telephones the Princess of Wales to ask what
her son would like for Christmas.

Noo, fit wid he like for his Christmas, the loon? Fit aboot a pair o’
fitba beets? Beets. Beets. B-O-O-T-S, beets. Weel, I ken that, but
he’ll surely grow intae them. Weel I’ll tell ye fit I’ve got. It’s
something very suitable. It’s oor ain special line in soft toys, and
it is a cuddly futret. A futret. Div ye nae ken fit a futret is?
Futret. F-E-R-R-E-T, futret. Now, cuddly futrets is exclusive tae the
Toy Shop, Ballater. We get them specially made up by a wee wifie, in
Hong Kong. Oh, an’ fit a job I hid explainin’ tae her fit a futret is.
Ye wid like a futret? Oh we’ll fairly manage ye a futret. Noo fit size
o’ a futret wid ye like? We’ve got a dinkie futret, a mini futret, a
life-size futret, a jumbo futret or a mega-futret. Ye’d like a jumbo
futret? No, it disnae hae a trunk. No, it’s got a string that ye pull,
an’ it sings Run, Rabbit, Run. Weel, fit else div ye expect a futret
tae sing? Now is there onythin’ else the loon wid like? Fit aboot a
rubber duke...for his bath? A duke. No, no, nae that kinda Duke.
D-U-C-K, duke. A quack quack duke. Like Donald Duke. Donald Duke. He’s
a freen’ o’ Mickey Moose...Moose.. .M-O-U-S-E, Moose! God, div ye nae
understan’ English, lassie?

This extract is interesting for a number of reasons. First of all,
obviously, it illustrates some of the stereotypical features of NE
Scots: the /f/ phoneme in ‘fit’, the /i/ in ‘beets’ and the /dj/ in
‘duke’, as in ‘Donald Duke’. Other features (such as the /u/ in
‘moose’ are shared with most other varieties of Scots. One obvious way
of approaching this text would be to ask what characteristics are true
of the pupils’ own variety of Scots, and what characteristics are not.
http://www.arts.gla.ac.uk/scotlit/as...pproaches.html

Nov 17 '07 #9

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

Similar topics

1
2215
by: baylor | last post by:
In C#, an interface cannot mark any method as static. i'm told the ILASM supports it but i've never tested that Two questions. First, why? OK, i've heard the reason about interfaces being allocated on the stack but that's not a real reason. Which is OK because this isn't a real question, it's just a complaint dressed up to look like a reason Second question. If a language doesn't support a fairly obvious feature, one has to wonder if...
30
2518
by: Frank Rizzo | last post by:
We are having one of those religious debates at work: Interfaces vs Classes. My take is that Classes give you more flexibility. You can enforce a contract on the descendant classes by marking methods abstract (which is all that an interface does). In addition, the classes allow you to be flexible by adding functionality that child classes inherit. Or by providing optional functionality via virtual methods. Now, I understand that...
8
1786
by: John | last post by:
What is the purpose / benefit of using an interface statement? It doesn't seem like anything more than a different way to make a class... (except you can't define any procedures in an interface like you can do in a class). I'm obviously missing something... John
9
5202
by: Sean Kirkpatrick | last post by:
To my eye, there doesn't seem to be a whole lot of difference between the two of them from a functional point of view. Can someone give me a good explanation of why one vs the other? Sean
18
1989
by: _dee | last post by:
Question about best use of interfaces: Say there's a 'Master' class that needs to implement a few interfaces: class Master : I1, I2, I3 { } The actual code already exists in smaller classes that each
22
2118
by: RSH | last post by:
Hi, I have been reading on interfaces working on samples I've run across on the web. For the life of me I cannot seem to grasp them. It appears to me that interfaces are simply blueprints to a class, that when implemented, they require the implementing calss to make sure that each of the properties, functions etc. are handled by the class. (????) What I am really having a problem with is how they overcome the limitation
18
2395
by: Tony | last post by:
class Interface { public: virtual void DoItNow()=0; }; class A: public Interface { public: void DoItNow(); // satisfies interface explicitly
5
3019
by: =?Utf-8?B?UmljaA==?= | last post by:
Greetings, I am actually a VB.Net guy, but I have worked somewhat with C++ and C#. I just want to ask about the relationship between Abstract Classes and Interfaces. My first question is if C# even has Iinterfaces. I took some Java programming classes and Interfaces are a main staple of Java. And in VB.Net I use interfaces for setting up definitions of classes. I am guessing that Abstract classes in C# do the same thing as...
10
2006
by: hyperboreean | last post by:
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.
23
2225
by: A.Gallus | last post by:
If I declare a function pure virtual: class A { virtual void myfunc() = 0; } and I derive a class from A: class B : public A
0
9721
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9603
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10376
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10120
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7662
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6881
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5689
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3861
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3015
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.