Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Re: Missing interfaces in Python...

Reply
Thread Tools

Re: Missing interfaces in Python...

 
 
Jonathan Daugherty
Guest
Posts: n/a
 
      04-17-2006
# so with interfaces, missing methods will suddenly appear out of thin
# air ?

With interfaces, the idea is that they're enforced; so, they'll appear
because someone implements them.

--
Jonathan Daugherty
http://www.parsed.org
 
Reply With Quote
 
 
 
 
redefined.horizons@gmail.com
Guest
Posts: n/a
 
      04-17-2006
Thanks for the responses...Looks like I might have opened Pandora's box
here. Could I accomplish the above with an abstract class?

If the mechanic class had a "fixIt()" method defined, could I pass it
any object I wanted, and then just call the method that I expect to
find there, or do I need to strictly define the type, or class, of an
object that is passed to a method.

Scott Huey

 
Reply With Quote
 
 
 
 
Jonathan Daugherty
Guest
Posts: n/a
 
      04-17-2006
# Thanks for the responses...Looks like I might have opened Pandora's
# box here. Could I accomplish the above with an abstract class?

Zope 3 has an interface system which is good. I recommend you look at
that.

--
Jonathan Daugherty
http://www.parsed.org
 
Reply With Quote
 
Fredrik Lundh
Guest
Posts: n/a
 
      04-17-2006
http://www.velocityreviews.com/forums/(E-Mail Removed) wrote:

> If the mechanic class had a "fixIt()" method defined, could I pass it
> any object I wanted


absolutely.

> and then just call the method that I expect to find there


yes.

> or do I need to strictly define the type, or class, of an object that is
> passed to a method.


no. this is Python. no need to negotiate with the compiler; just do what
you want, and the interpreter will tell you when that doesn't work.

also see:

http://en.wikipedia.org/wiki/Duck_typing

</F>



 
Reply With Quote
 
Benji York
Guest
Posts: n/a
 
      04-17-2006
Jonathan Daugherty wrote:
> # Thanks for the responses...Looks like I might have opened Pandora's
> # box here. Could I accomplish the above with an abstract class?
>
> Zope 3 has an interface system which is good. I recommend you look at
> that.


Zope 3's interface system is quite good, but it's also quite different
from what he's probably expecting. On the up side, it's probably much
better than what he's expecting too.
--
Benji York

 
Reply With Quote
 
Serge Orlov
Guest
Posts: n/a
 
      04-17-2006

Jonathan Daugherty wrote:
> # so with interfaces, missing methods will suddenly appear out of thin
> # air ?
>
> With interfaces, the idea is that they're enforced; so, they'll appear
> because someone implements them.


But if you're writing tests you will check method signatures anyway, so
why bother? Besides how java-like interfaces will help you if one of
interface methods is supposed to accept one parameter that can be list
or dict and not accept None?

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
show interfaces trunk cmd missing Tom Cisco 5 05-03-2009 12:22 PM
Am I missing something with Python not having interfaces? jmDesktop Python 25 05-13-2008 09:45 AM
Interfaces Question - I am missing something jmDesktop Java 9 05-12-2008 01:41 PM
Re: missing feature classes and missing fields Gary Herron Python 2 07-04-2006 10:29 PM
Missing interfaces in Python... redefined.horizons@gmail.com Python 43 04-24-2006 11:20 AM



Advertisments