PEP 245

Alex Shindich alex at shindich.com
Sun Apr 1 19:30:32 EDT 2001


>  [Previous]   [Next]   [Reply]   [Index]   [Home]   [Find]
>
>    * Newsgroups: comp.lang.python
>    * From: qrczak at knm.org.pl (Marcin 'Qrczak' Kowalczyk)
>    * Subject: Re: PEP 245
>    * Date: 1 Apr 2001 13:26:49 GMT
>    * Organization: Klub Nieszkodliwych Manjaków
>
>   ------------------------------------------------------------------------
>
> Sun, 1 Apr 2001 00:21:05 -0800 (PST), Alex Shindich <alex at server01.shindich.com> pisze:
>
> > 1. What is the point of interfaces without static typing?
>
> To formalize requirements about objects.
>
> To get better error messages early, instead of cryptic errors raised
> deep where the object was finally actually used.

Try this:
class MyInterface:
    def foo (self):
        """
        """
        raise UnimplementedMethodException ("Method foo is not implemented.")

class ConcreteClass (MyInterface):
    ...

>
> > There is no guarantee that method doSomething declared in the
> > interface has anything in common with the method doSomething declared
> > in the concrete implementation class.
>
> It cannot be guaranteed in general in any framework. But an interface
> implies some properties of its methods and objects should be declared
> as conforming to an interface only if their methods really have an
> appropriate meaning.

All it guarantees is that the concrete class has methods with the same names as those in
the interface.

> > If the compliance is checked at run time, then interface checking is
> > as good as as simply assuming that the method is implemented. Today,
> > I can compile code like "f.doSomething ()" without f actually
> > implementing doSomething. At run time I would get an AttributeError
> > thrown into my face.
>
> You may get the error too late or with unhelpful error message, and
> you won't get the error if the object happens to have a method of
> the given name but the method means a completely different thing.
> And you don't have a hint what objects a method expects nor what
> objects it returns, besides some informal explanation in docs.

Huh? What do doc strings have to do with this? Document your base classes, and you will
get the same amount of documentation.
Also, how would error message like "InterfaceError: 'Foo' does not implement method 'Bar'"
be more helpful then "AttributeError: 'Foo' instance has no attribute 'Bar'"?

> 3. I am just curious... Does any one smell Java here?

>
> I would prefer to discuss features themselves than to draw conclusions
> from similarities to other languages, especially languages we don't like.

Hmm... I happened to like to Java... It's just that I use it when I need strong typing.
And I totally love Python,  and I use it whenever I can...

> --
>  __("<  Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/
>  \__/
>   ^^                      SYGNATURA ZASTĘPCZA
> QRCZAK
>
>   ------------------------------------------------------------------------
> Mailgate References:
>   PEP 245, Alex Shindich
>   ------------------------------------------------------------------------
>  [Previous]   [Next]   [Reply]   [Index]   [Home]   [Find]
> Mailgate.ORG is maintained online by Dario Centofanti

--
Alex Shindich
mailto:alex at shindich.com
Visit http://www.shindich.com/


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20010401/c7cb37ba/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: alex.vcf
Type: text/x-vcard
Size: 194 bytes
Desc: Card for Alex Shindich
URL: <http://mail.python.org/pipermail/python-list/attachments/20010401/c7cb37ba/attachment.vcf>


More information about the Python-list mailing list