Python Forum
"add to list" function - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/Forum-Python-Coding)
+--- Forum: General Coding Help (https://python-forum.io/Forum-General-Coding-Help)
+--- Thread: "add to list" function (/Thread-add-to-list-function)



"add to list" function - P13N - Jan-11-2019

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



RE: "add to list" function - ichabod801 - Jan-11-2019

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.


RE: "add to list" function - P13N - Jan-11-2019

Thanks! Lost the bracket while pasting the code in here.