I'm trying to append an item to an argument of an external class which is a list but I need to create an instance. But how do I create an instance to that class's arguments without using that same class instance? here is a little example of what I'm trying to do
class A(object):
def __init__(self, list1, arg1)
self.list1 = list1
self.arg1 = arg1
class B(object):
def __init__(self, arg2, arg3)
self.arg2 = arg2
self.arg3 = arg3
def method1(self, arg4)
self.arg4 = arg4
if 0 < 1:
A(A.list1, A.arg1).list1.append('newitem')
return list1
What should I do to append that newItem to list1?
I'm sorry if i don't explain myself well. i'm really confused
EDIT (adding my actual code)
class SimpleVirus(object):
def __init__(self, maxBirthProb, clearProb):
self.maxBirthProb = maxBirthProb
self.clearProb = clearProb
def reproduce(self, popDensity):
self.popDensity = popDensity
reproduceProb = self.getMaxBirthProb() * (1 - popDensity)
child = SimpleVirus(self.getMaxBirthProb(), self.getClearProb())
VirusL = Patient.getVirusesList()
if random.random() <= reproduceProb:
#Down here is where I need to append to the "viruses" list
Patient(viruses, maxPop).viruses.append(child)
return child
else:
raise NoChildException()
class Patient(object):
def __init__(self, viruses, maxPop): #viruses is a list
self.viruses = viruses
self.maxPop = maxPop