[EMAIL PROTECTED] wrote: > I have the argument items in my class room. > > class room: > def __init__(self, name, description, items*): > > I thought I remembered from a tutorial I read once, and I've read so > many I feel like an expert of them, that putting a little star* above > an item makes it accept the argument as a list. But when I tried this, > I got an invalid syntax error message. > There is an error in the syntax the star must prefix the variable name not suffix it. Then the items variable will accept the parameter value as a tuple. > So: > Question 1: How can I create an argument that accepts a list of > variable? It is not clear whether you want to accept a list variable or an arbitrary number of values as parameter to the function. So I will explain each case. def ex(name,*items): Here name, description and items can all accept lists as arguments. Additionally items can accept arbitrary number of arguments even of different types. Ex: ex([10,12],12,13.3,'Python') > > Question 2: How do I signify to accept each item as one list? (my bet's > on using another set of parens) I have answered this already. > > Question 3: Or am I going about this all wrong and should always create > a list before the fuction call and use the list in the function call? No need u can pass a list directly into the call.
-- http://mail.python.org/mailman/listinfo/python-list