[Tutor] Tuple: Am I Understanding This Correctly?

Alan Gauld alan.gauld at btinternet.com
Wed Dec 14 19:25:33 CET 2011


On 14/12/11 15:48, Homme, James wrote:
>  Am I explaining how this works correctly?

You are not really explaining *how* it works, just saying what it does.
What you are doing is sensible iff you have many places where the tuple 
is useful. In the specific case I'd personally just create the tuple at 
the point of use:

> finish = (user_name, prompt)
> likes = raw_input("Do you like me %s?\n%s" % finish)

likes = raw_input("Do you like me %s?\n%s" % (user_name, prompt))

Since it saves the reader referring back to the definition
of finish (which is an odd nanme for user/prompt data IMHO).

> # Use the tuple repeatedly when asking other questions.

But, if you are using the tuple repeatedly then it starts
to make sense.

-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/



More information about the Tutor mailing list