SV: Python Productivity over C++

Thomas Thiele thiele at muc.das-werk.de
Wed Jun 14 14:09:37 EDT 2000


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.




More information about the Python-list mailing list