join()

Huaiyu Zhu hzhu at users.sourceforge.net
Fri Oct 6 21:36:19 EDT 2000


On Sat, 07 Oct 2000 00:40:28 GMT, echuck3 at my-deja.com <echuck3 at my-deja.com>
wrote: 
>In article <39DD9A9A.7130 at hvision.nl>,
>  ivnowa at hvision.nl wrote:
>>
>> The problem is that string.join does not work on a list... it works
>on a
>> *sequence*. These are all valid:
>
>Ah, I see your point. That brings me to my next suggestion: That types
>can inherit from each other and that we make an abstract Sequence type
>from which List, Tuple and possibly String all inherit from.

The normal kind of inheritance would not work generally.  Suppose Python
start with list only, there would be no need to have an abstract sequence
type.  Then when we have more of these, like tuples and strings and
UserList, we can see the need, but it needs retrofitting all these types.
Now of course this is not historically correct, but you get the idea.

The typical OO philosophy is to always start with the most abstract.  Java
takes this to quite some extreme.  In order to print a floating number in
the "%6.3f" format you need to go through something like
java.lang.text.format. blah, blah, blah.

What is really needed is an abstraction mechanism, so that we can define the
abstract form AFTER the special forms.  This way, somebody someday may say:
Hey, I need a writable file here, and I can use any of open(name,"w") kind
of objects, or sys.stdout, or MyOutStream, or any other object with a write
method - and he promptly defines WritableFile, and specifies these cases.

See http://www.geocities.com/huaiyu_zhu/python/Interface/README.txt
and http://www.geocities.com/huaiyu_zhu/python/Interface/typecheck.txt
for some further discussions related to type checking.

Huaiyu



More information about the Python-list mailing list