Python Forum
"add to list" function - Printable Version

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



"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.