Static typing (was Re: Java guy interested in Python)
Hamish Lawson
hamish_lawson at yahoo.co.uk
Fri Mar 9 04:52:09 EST 2001
Michael Hudson wrote:
> If you type-annotate this, you might write (using entirely made up
> syntax):
>
> def write16(file : <file>, int : <int>):
> file.write(struct.pack("h",int))
>
> but then what about passing in a StringIO object, or some user
> wrapper of a file object? What makes a "<file>"? At the moment,
> it's just a loose collection of methods, some of which are optional
> in some circumstances.
Wouldn't there be a hierarchy of interface types for file-like objects,
with some interfaces specifying more methods than others? You'd then
choose the interface type that specified the collection of methods that
you require of your passed object.
Not-that-I'd-necessarily-want-this-all-of-the-time-ly yours,
Hamish Lawson
____________________________________________________________
Do You Yahoo!?
Get your free @yahoo.co.uk address at http://mail.yahoo.co.uk
or your free @yahoo.ie address at http://mail.yahoo.ie
More information about the Python-list
mailing list