[Tutor] I'm just full of questions today

Daniel Yoo dyoo@hkn.eecs.berkeley.edu
Sat, 28 Oct 2000 23:59:51 -0700 (PDT)

On Sun, 29 Oct 2000, wheelege wrote:

>   Hmm....problem is, I'm trying to get about 50 arguments in there.  Well,
> not 50 but close to it.  Isn't there a way to say, eg

Hint: if you're going to have fifty variables, you might consider using a
single list structure instead.  Otherwise, you will be in severe pain
typing all of those variables.

So instead of:

    somefunction(x1, x2, ..., x50)

using lists will make that hideous expression much more compact:


And it's fairly straighforward to create and use lists:

    square = [ (0,0), (1,0), (1,1), (0,1) ]
    triangle = [ (0,0), (1,0), (0,1) ]
    shapes = [square, triangle]
    # ... etc
    first_coord = square[0]   # retrieving the first coordinate
    x, y = first_coord        # and breaking it down into x and y

You really really want to work with lists if you're dealing with long
sequences, expecially sequences of coordinates.  If you're unfamiliar with
lists, email us, and we can show you how lists work.