Linked Questions

Popular Questions

I am fairly new to the concept of decorators.

I am trying to implement a function which creates a list of random integers and set it to the group_list variable in the __init__ method.

And the second method takes an input from the user and set it to the value variable in the __init__ method.

class Order(object):

def __init__(self, group_list=None, value=None):
    self.group_list=groupList
    self.value=number
    print(self.groupList)


@property
def groupList(self):
    return self._groupList

@groupList.setter
def _groupList(self):
    global list_val
    for _ in range(10):
        currentelement= randint(1,15)
        list_val.append(currentelement)
    self._groupList=list(set(list_val))

@property
def number(self):
    return self._number

@number.setter
def number(self):
    val=input('Enter any number from the list: ')
    self._number=val

What am I doing wrong here ? Any help will be highly appreciated!

Related Questions