[Tutor] Beginner Exercise: Why Didn't I Break It?

Homme, James james.homme at highmark.com
Tue Dec 20 19:10:43 CET 2011


Hi Jerry,
Thank you. This reminds me of single dimension arrays in VBScript. Note that I said Reminds. I'm trying to pretend I don't know about other languages, so I can give myself less learning stress.

thanks.

Jim

-----Original Message-----
From: tutor-bounces+james.homme=highmark.com at python.org [mailto:tutor-bounces+james.homme=highmark.com at python.org] On Behalf Of Jerry Hill
Sent: Tuesday, December 20, 2011 1:00 PM
To: tutor at python.org
Subject: Re: [Tutor] Beginner Exercise: Why Didn't I Break It?

On Tue, Dec 20, 2011 at 12:31 PM, Homme, James <james.homme at highmark.com> wrote:
> So far, the data types this little book has talked about are strings and numbers.
...
> return jelly_beans, jars, crates
...
> # It returns three things in parentheses, which, I guess is one group of things. I thought it would complain.


You book may not have talked about it yet, but there is a third data
type involved here, a tuple.  The secret_formula() function doesn't
actually return three separate things.  It returns a single object
that contains a sequence of three other objects.  In this case, it
specifically returns a tuple (rather than a list or other sequence
type).

Take a look here
http://docs.python.org/tutorial/datastructures.html#tuples-and-sequences
for more about tuples in particular, and the rest of that page for an
overview of sequence types in general.

>beans, jars, crates = secret_formula(start_point)

This line performs what python calls "sequence unpacking" (sometimes
also called "tuple unpacking").  That's described in the same link I
referenced above.

Hopefully that gives you a few places to read more without explaining
the whole thing.

--
Jerry
_______________________________________________
Tutor maillist  -  Tutor at python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

________________________________

This e-mail and any attachments to it are confidential and are intended solely for use of the individual or entity to whom they are addressed. If you have received this e-mail in error, please notify the sender immediately and then delete it. If you are not the intended recipient, you must not keep, use, disclose, copy or distribute this e-mail without the author's prior permission. The views expressed in this e-mail message do not necessarily represent the views of Highmark Inc., its subsidiaries, or affiliates.


More information about the Tutor mailing list