why?
bradh at cuneata.net
bradh at cuneata.net
Mon Dec 2 19:10:26 EST 2002
Quoting Brian Quinlan <brian at sweetapp.com>:
> > You can, if you say doing[1] = ('i') which to my (very newbie)
> > thinking is assignment of a tuple to a string. I can't see how
> > it is more valid to assign a tuple to a string, rather than a
> > string to a string.
>
> This is your conceptual problem. Why do you think it matters what
> doing[1] used to be? It doesn't.
OK, so doing[1] is really just a reference. And we can move the
reference around to be a reference to a tuple.
But that doesn't really explain why I can't assign a string to doing[1].
Or why the OP can't do the assignment :)
Unless maybe the assignment of a tuple actually changes the object
that doing is a reference to.
The specific question is why is
doing[1] = 'i' #not valid
doing[1] = ('i') #valid
?
Brad
More information about the Python-list
mailing list