473,388 Members | 953 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,388 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 1480
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
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,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.