By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,772 Members | 906 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,772 IT Pros & Developers. It's quick & easy.

Interfaces.

P: n/a
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
Share this Question
Share on Google+
8 Replies


P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.