En Fri, 09 Mar 2007 23:58:59 -0300, Steven D'Aprano <[EMAIL PROTECTED]> escribió:
> You know, now that Python has a warnings module, it would be really good > if list-of-lists*int raised a warning. Does anyone know if that's > feasible > or possible? It needn't catch every imaginable Gotcha, just the common > case. I'm thinking something like this: > > # pseudo-code > class list: > def __mul__(self, count): > for item in self: > if isinstance(item, list): > warn("this duplicates references, not copies") > break > ...do the rest But isn't the same with almost any other object (except inmutable ones)? [{}]*5, [set()]*5, even [my_instance]*5? It's hard to tell when it's a legitimate use and when it's a mistake, and the checking+warning call has a cost... -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list