new to python - trouble calling a function from another function

Neil Cerutti neilc at norwich.edu
Thu Aug 5 17:42:48 CEST 2010


On 2010-08-05, Brandon McCombs <none at none.com> wrote:
> class Elevator(Process):
> def __init__(self,name):
>       Process.__init__(self,name=name)
>       self.numPassengers = 0
>       self.passengerList = []
>       self.passengerWaitQ = []
>       self.currentFloor = 1
>       self.idle = 1
>       self.newPassengers = 0
> def goUp(self):
>       print "here"
>       bubbleSort(self.passengerList, len(self.passengerList))
>       self.currentFloor += 1
>       if len(self.passengerList) > 0:
>          for p in self.passengerList:
>             if self.currentFloor == p.destination:
>               yield (p.destination - self.currenteFloor) * TRAVELTIME, self
>               reactivate(p)
>               p.inBuilding()
>             else:
>               self.goUp()
>
> def checkQueue(self):
>       if (len(self.passengerWaitQ)) > 0 and len(self.passengerList) < 
> MAXCAPACITY:
>       if len(self.passengerWaitQ) < MAXCAPACITY:
>           self.newPassengers = len(self.passengerWaitQ)
>       else:
>              self.newPassengers = MAXCAPACITY - len(self.passengerList)
>       for i in range(0,self.newPassengers):
>         self.passengerList.append(self.passengerWaitQ.pop())
>       self.goUp()


Does your program call checkQueue?

-- 
Neil Cerutti



More information about the Python-list mailing list