Typing system vs. Java

Bengt Richter bokr at accessone.com
Sat Aug 4 14:46:33 EDT 2001


On Sat, 04 Aug 2001 17:03:05 GMT, Courageous <jkraska1 at san.rr.com> wrote:

>
>>Since I can write more powerful programs in smaller, more readable 
>>chunks, I think I write less buggy code. If we have to reduce the 
>>simplicity/expressiveness of the language in order to add type-checking, 
>>then I think the tradeoff is not worth it.
>
>I emphatically agree. Syntactic type declaration is considerably out of
>place with Python.
>
>Although I was thinking about about something which might be useful.
>What if Python were to support a type consistency check on containers?
>
>>>> mylist = [1,2,"alpha"]!
>Type Consistency Error:
>>>>
>
>Note the exclamation point.
>
assert(type(mylist) in (type(()),type([])) and \
  len([x for x in mylist if type(x)!=type(mylist[0])])==0)

Would you use it often enough to warrant a language change?

OTOH, if '!' were a unary postfix operator that you could define ... ;-)

def __operator__!(mylist):
    return type(mylist) in (type(()),type([])) and \
  len([x for x in mylist if type(x)!=type(mylist[0])])==0)




More information about the Python-list mailing list