Bottom Page

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
Quote
#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

Quote
#3
Thanks! Lost the bracket while pasting the code in here.
Quote

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  generator function that yield from a list buran 9 349 Jun-04-2019, 10:26 PM
Last Post: snippsat
  AssertionError: View function mapping is overwriting an existing endpoint function Zhavi221 7 408 Apr-17-2019, 01:07 PM
Last Post: Zhavi221
  List creation and return in Function leoahum 3 152 Mar-04-2019, 04:45 PM
Last Post: leoahum
  Function to return modified list Pjones006 2 187 Feb-06-2019, 10:57 PM
Last Post: Pjones006
  Making list empty after return in function dan789 10 686 Nov-24-2018, 11:54 PM
Last Post: micseydel
  Run function in parallel but inherite dynamic data from the previous function atizva 4 630 Jul-11-2018, 06:39 AM
Last Post: volcano63
  function 'return' and file content into a list shiro26 4 541 Jul-06-2018, 10:20 PM
Last Post: volcano63
  question about list and remove function wmw12344 5 686 Mar-30-2018, 11:52 AM
Last Post: ljmetzger
  make a list of string in capital by using a function anancba 3 910 Nov-23-2017, 06:42 AM
Last Post: heiner55
  List in function thehimanshukeshri 1 914 Nov-19-2017, 07:58 AM
Last Post: buran

Forum Jump:


Users browsing this thread: 1 Guest(s)