SV: Python Productivity over C++

Gordon McMillan gmcm at hypernet.com
Wed Jun 14 17:10:30 EDT 2000


Thomas Thiele wrote: 

>Aahz Maruch wrote:
>
>> Suppose you needed a file object to connect to some chunk of memory. 
>> In other languages, you would need to inherit from the Python file
>> object in order to ensure that random functions that expect file
>> objects would still work.  In Python, that's completely unnecessary. 
>> It's probably a lot simpler to create your own class, complete with
>> open(), close(), read(), and write() methods -- and because you've
>> maintained *interface* consistency, you can use your new class
>> *ANYWHERE* a file object would go.
>> --

>But there is no mechanism to ensure that the behaviour of your
>memfileobjectsis like a fileobject. For instance if you don't note that
>you forgot to write the write()-function.
>In a worst case scenario it works for many months until a user calls a
>function in which
>the write() -function is needed.

And there's no mechanism to ensure that you have the behavior right in C++, 
even if the compiler accepted your interface.

Except good test cases, that is.

- Gordon




More information about the Python-list mailing list