Python Forum
Thread Rating:
  • 3 Vote(s) - 2.67 Average
  • 1
  • 2
  • 3
  • 4
  • 5
"add to list" function
#1
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
Reply
#2
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.
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply
#3
Thanks! Lost the bracket while pasting the code in here.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  I created a function that generate a list but the list is empty in a new .py file mrhopeedu 2 2,247 Oct-12-2019, 08:02 PM
Last Post: mrhopeedu

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020