473,326 Members | 2,126 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,326 software developers and data experts.

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 1478
On Nov 15, 8:55 pm, "PeterBrad...@googlemail.com"
<PeterBrad...@googlemail.comwrote:
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 NotImplementedError.
Nov 16 '07 #2
En Thu, 15 Nov 2007 22:55:13 -0300, Pe**********@googlemail.com
<Pe**********@googlemail.comescribió:
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...@googlemail.com"
<PeterBrad...@googlemail.comwrote:
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...@googlemail.com"
<PeterBrad...@googlemail.comwrote:
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...@googlemail.com"
<PeterBrad...@googlemail.comwrote:
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**********@googlemail.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.comwrote :
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
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...
30
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...
8
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...
9
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
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...
22
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...
18
by: Tony | last post by:
class Interface { public: virtual void DoItNow()=0; }; class A: public Interface { public: void DoItNow(); // satisfies interface explicitly
5
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...
10
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...
23
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
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
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: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
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...
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
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.