May-31-2021, 07:18 PM
(May-31-2021, 12:32 PM)BashBedlam Wrote: Your function is not returning anything. Try it like this:
#Create arbitrary class class Object(): def __init__(self,value1,value2,value3): self.v1=value1 self.v2=value2 self.v3=value3 #Create an arbitrary object D=Object(2,3,"abc") #Function to create a new object based on the previous def new_object(A): #Here we get keys a=[] a=list(A.__dict__.keys()) for i in range(len(a)): if type(getattr(A, a[i])) != int: delattr(A, a[i]) print(A.__dict__.keys()) return Object (a[0], a[1], 0) #New object Z=new_object(D) print (type (Z))
Thank you very much