why?
Dennis Lee Bieber
wlfraed at ix.netcom.com
Mon Dec 2 20:18:38 EST 2002
bradh at cuneata.net fed this fish to the penguins on Monday 02 December
2002 03:44 pm:
>> > >>> doing = ['a','b','c']
>> > >>> doing[1] = ('b','c')
> doing[1] is a string, and it shouldn't be possible to
> assign to an immutable object.
>
doing[1] is a list element, said element just happens to contain a
string. You are free to replace the list element.
Look at it using more than single character strings...
doing = ['string1', 'astring', 'strings']
doing[1] = ('new', 'tuple', 'string')
print doing[2][3] #fourth character in third string
doing[2][3] = 'u' #ERROR
> This is irrelevant. doing[1] should be the same as doing[1][0]
> in this particular case.
>
The /visual/ result looks the same -- but the first is a list element
containing a string, the second is a character within the string.
--
> ============================================================== <
> wlfraed at ix.netcom.com | Wulfraed Dennis Lee Bieber KD6MOG <
> wulfraed at dm.net | Bestiaria Support Staff <
> ============================================================== <
> Bestiaria Home Page: http://www.beastie.dm.net/ <
> Home Page: http://www.dm.net/~wulfraed/ <
More information about the Python-list
mailing list