i am trying to assign the return values from the classmethod to the init method variables but shows the error "TypeError: cannot unpack non-iterable NoneType object"
i tried assigning to one variable and could see that it returns "tuple"
class port_mappings: ip_prefix=[] def __init__(self,node1_id,node2_id): self.node1_id=node1_id self.node2_id=node2_id self.node1_ip,self.node2_ip= port_mappings.gen_ip_prefix() @classmethod def gen_ip_prefix(cls): if len(cls.ip_prefix)==0: cls.ip_prefix.append("10.0.0.0/31") print(cls.ip_prefix) return "10.0.0.0/31","10.0.0.1/31" else: pass node_list=port_mappings("95","96") Since it is returning the tuple, i am trying the following but
self.node1_ip,self.node2_ip= port_mappings.gen_ip_prefix() it shows the following error
TypeError: cannot unpack non-iterable NoneType object
len(cls.ip_prefix) != 0, then your function goes into theelse: passand returnsNone.