Tuples and immutability

Mark H. Harris harrismh777 at gmail.com
Sat Mar 1 00:50:44 EST 2014


On Friday, February 28, 2014 11:34:56 PM UTC-6, Ian wrote:

> One very common example of tuples containing lists is when lists are
> passed to any function that accepts *args, because the extra arguments
> are passed in a tuple.  A similarly common example is when returning
> multiple objects from a function, and one of them happens to be a
> list, because again they are returned in a tuple.

>     def f(*args):
>         print(args)
>         return (args[1:]
> 
>     >>> result = f(1, 2, 3, [4, 5])
>     (1, 2, 3, [4, 5])
>     >>> print(result)
>     (2, 3, [4, 5])

I agree Ian... good points all.   ... again, I'm not arguing with anyone... just saying that an error (whatever we mean by that) should not half-way-fail....   we are only pointing out the problem... we have not idea what the solution is yet. 

Intuitively everyone can see that there is a problem here...  the debate cannot be answered either because of the inherent design of python (almost all of which we love). So, as they say, what is a mother to do?  ... I mean, some people's kids... 

I don't know how I propose to handle the problem... I think the first step is getting everyone to agree that there IS a problem... then debate how to tackle the solution proposals.

marcus



More information about the Python-list mailing list