Lists and Tuples and Much More

2007-04-12 Thread Scott
I'm going to start grouping all my questions in one post as this is my second today, and sorta makes me feel dumb to keep having to bother you all with trivial questions. I'll just seperate my questions with:

Re: Lists and Tuples and Much More

2007-04-12 Thread bearophileHUGS
Scott: Others will give you many more answers, here is just a bit. > And how would you sort the list that's in the list? I guess that goes in > conjunction with the section above, but still: >>> my_list = [6, 4, 3, 5, 2, 1] > >>> my_list.append([7, 9, 8, 10]) > >>> my_list.sort() > >>> my_list >

Re: Lists and Tuples and Much More

2007-04-12 Thread Daniel Nogradi
> And the last example brings up another question. What's the deal with a > tupple that has a list in it such as: > > >>>my_tupple = (1, 2, 3, 4, 5, [6, 7, 8, 9]) > > Now I read somewhere that you could change the list inside that tupple. But > I can't find any documentation that describes HOW to

Re: Lists and Tuples and Much More

2007-04-12 Thread 7stud
> Now I read somewhere that you could change the > list inside that tupple. But I can't find any > documentation that describes HOW to do it. t = (1, 2, ["red", "white"]) t[2][1] = "purple" print t t[2] returns the list, so the second line is equivalent to: lst = t[2] lst[1] = "purple" That is

Re: Lists and Tuples and Much More

2007-04-12 Thread Ben Finney
"Scott" <[EMAIL PROTECTED]> writes: > I'm going to start grouping all my questions in one post as this is > my second today, and sorta makes me feel dumb to keep having to > bother you all with trivial questions. No, please don't do that. Separate questions leading to separate discussions should

Re: Lists and Tuples and Much More

2007-04-12 Thread Gabriel Genellina
En Thu, 12 Apr 2007 19:38:55 -0300, Scott <[EMAIL PROTECTED]> escribió: > List's and Tuple's > I don't see the distinction between the two. I mean, I understand that a > list is mutable and a tuple is immutable. > The thing that I dont understand about them is what, besides that, > seperates

Re: Lists and Tuples and Much More

2007-04-12 Thread 7stud
> Yes. Tuples are immutable - once created, they can't change. Just to explain that statement a little better. If you do this: t = (1, 2, ["red", "white"]) t[2].append("purple") print t#(1, 2, ['red', 'white', 'purple']) It sure looks like t changed, and therefore t is NOT immutable--and

Re: Lists and Tuples and Much More

2007-04-12 Thread [EMAIL PROTECTED]
On Apr 12, 5:38 pm, "Scott" <[EMAIL PROTECTED]> wrote: > I'm going to start grouping all my questions in one post as this is my > second today, and sorta makes me feel dumb to keep having to bother you all > with trivial questions. I'll just seperate my questions with: > ---

Re: Lists and Tuples and Much More

2007-04-12 Thread Mel Wilson
Scott wrote: > Now I read somewhere that you could change the list inside that tupple. But > I can't find any documentation that describes HOW to do it. The only things > I CAN find on the subject say, "Don't do it because its more trouble than > it's worth." But that doesn't matter to me, be

Re: Lists and Tuples and Much More

2007-04-12 Thread Paul McGuire
On Apr 12, 5:38 pm, "Scott" <[EMAIL PROTECTED]> wrote: > I'm going to start grouping all my questions in one post as this is my > second today, and sorta makes me feel dumb to keep having to bother you all > with trivial questions. You might also investigate the python tutorial mailing list, which

Re: Lists and Tuples and Much More

2007-04-13 Thread Steven D'Aprano
On Thu, 12 Apr 2007 16:01:51 -0700, bearophileHUGS wrote: >> [1, 2, 3, 4, 5, 6, [7, 9, 8, 10]] > > Such sorting may be impossible in Python 3.0 (comparing the order of > lists with integers may be seen as meaningless. Otherwise you can see > single numbers as lists of len=1, like another language

Re: Lists and Tuples and Much More

2007-04-13 Thread Scott
"7stud" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] >> Yes. Tuples are immutable - once created, they can't change. > > Just to explain that statement a little better. If you do this: > > > t = (1, 2, ["red", "white"]) > t[2].append("purple") > print t#(1, 2, ['red', 'white',

Re: Lists and Tuples and Much More

2007-04-14 Thread Hendrik van Rooyen
"7stud" <[EMAIL PROTECTED]> wrote: > .. But using a tuple as a > key in a dictionary is probably something you will never do. Yikes! I do this all the time... Think of an address in any one town. It has a Street, and a number (could be more complex, like a sub number for an apartme

Re: Lists and Tuples and Much More

2007-04-14 Thread James Stroud
Hendrik van Rooyen wrote: > > "7stud" <[EMAIL PROTECTED]> wrote: > > >>.. But using a tuple as a >>key in a dictionary is probably something you will never do. > > > Yikes! I do this all the time... > > Think of an address in any one town. > It has a Street, and a number > (could

Re: Lists and Tuples and Much More

2007-04-14 Thread Alex Martelli
7stud <[EMAIL PROTECTED]> wrote: > It sure looks like t changed, and therefore t is NOT immutable--and > the whole "tuples are immutable" mantra is a lie. However, the list """ So, "the statue that points to Hotel Belfiore" h

Re: Lists and Tuples and Much More

2007-04-15 Thread Hendrik van Rooyen
"James Stroud" <[EMAIL PROTECTED]> wrote: > Hendrik van Rooyen wrote: > > > > But if you limit it to one thing and its inverse, its quite useful, and it > > would be nice to have one "doubledict" that can be accessed as speedily > > from either end... > > > > Sort of an internally linked list of