Class
trying it out
Get error on bold line 5 >> data.append(k)
Newbie here, what am i doing wrong?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
import datetime as dt class Defaults: """Storage of Default Values""" dbConStr = "pass:Name:Database;" baseDate = dt.datetime( 2000 , 12 , 31 ) baseVal = int ( 100 ) class myStructure: """ My custom data structure for arrays """ def __init__( self , date1 = dt.datetime( 2000 , 12 , 31 ), num1 = 0 , str1 = "Nothing" ): self .date1 = date1 self .num1 = num1 self .str1 = str1 class MySmartList(): """ Smart list with field data IDs """ def __init__( self ): data = [] def AddNewRec( self , date1 = "05/01/1950" , num1 = 0 , str1 = "Nothing" ): #Accepted date format 05/01/1950 zDate = dt.datetime.strptime(date1, "%m/%d/%Y" ) k = myStructure(zDate, num1, str1) data.append(k) |
1 2 3 4 5 |
# Smart List myData = [] my.MySmartList.AddNewRec(myData,date1 = "05/01/1950" ,num1 = 100 ,str1 = 'Test0' ) my.MySmartList.AddNewRec(myData,date1 = "05/02/1950" ,num1 = 101 ,str1 = 'Test1' ) my.MySmartList.AddNewRec(myData,date1 = "05/03/1950" ,num1 = 102 ,str1 = 'Test2' ) |
1 2 3 4 5 |
def AddNewRec( self , date1 = "05/01/1950" , num1 = 0 , str1 = "Nothing" ): #Accepted date format 05/01/1950 zDate = dt.datetime.strptime(date1, "%m/%d/%Y" ) k = myStructure(zDate, num1, str1) data.append(k) |