Python Forum

Full Version: "add to list" function
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
The following function should generate a list from my class - right?

def to_list(self):
        return [self.customer_id, self.firstname, self.lastname, self.born, self.zip_code
Well, it needs a closing bracket (]) at the end of the second line, but otherwise, yeah. Note that you have to put that indented under the class definition (to automatically pass self), or you need to manually pass the function an instance of your class.
Thanks! Lost the bracket while pasting the code in here.