Collections of non-arbitrary objects ?

Marc 'BlackJack' Rintsch bj_666 at gmx.net
Sat Jun 23 21:12:02 CEST 2007


In <1182620734.940718.196520 at e16g2000pri.googlegroups.com>, walterbyrd
wrote:

> On Jun 22, 11:43 pm, Ben Finney <bignose+hates-s... at benfinney.id.au>
> wrote:
> 
>> Can you help us understand, by showing a use case that would in your
>> estimation be improved by the feature you're describing?
>>
> 
> Suppose you are sequentially processing a list with a routine that
> expects every item to be of a certain type. Something in the list that
> doesn't conform to the type could give you unexpected results, maybe
> crash your application.

It raises an exception.  What want you an "typed list" to do when a wrong
object is put into it?  Raising an exception?  So all you change is the
point in time when the exception is raised.

> In python, as far as I know, there is nothing built into the language
> to keep any type of item from being included in a list - or any such
> structure. To me, that seems like a potentially vulnerability.
> Especially since variables in python do not have to be explicitly
> assigned - another variable that points to the same thing, could
> change the data that a variable points to.

But this doesn't really change with a "typed list".  It's easy to take
an object and completely replace all its attributes so it behaves very
different.

Ciao,
	Marc 'BlackJack' Rintsch



More information about the Python-list mailing list