how to mutate a tuple?
Carlo v. Dango
oest at soetu.eu
Tue Oct 14 09:48:30 EDT 2003
More information about the Python-list mailing list
Tue Oct 14 09:48:30 EDT 2003
- Previous message (by thread): how to mutate a tuple?
- Next message (by thread): how to mutate a tuple?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Tue, 14 Oct 2003 09:33:46 -0400, Roy Smith <roy at panix.com> wrote: Many thanks for your quick reply! aaaahh so there is a tuper() construct! :) that helps a lot.. still this seems rather inefficient to create a list and then a new tuple.. but I guess there really is no easier way. but is there a tuple=>list function ? so that instead of creating the list by a for-construct I could just say list = tuple.tolist() list[0] = newval return turple(list) ? -c.v.d. > Copy your input tuple to a list, then say "myTuple = tuple (myList)" > > myList = [] > for item in myInputTuple: > if this is the item that needs changing: > item = something else > myList.append (item) > > return tuple (myList) --
- Previous message (by thread): how to mutate a tuple?
- Next message (by thread): how to mutate a tuple?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list