Adding to a List and displaying quantity in the list



Hi
I have coded a program whihc outputs what I like, but I am trying to modify it to add specific result info to a list and then display the number of items in the list. This is easy for me with basic code, but seems difficult when trying to adapt my program.
My code and explanation is as follows:

class Source(Process):
""" Source generates customers randomly """

def generate(self, number, meanTBA, resource):
for i in range(number):
c = Customer(name="Customer%02d" % (i+1,))
activate(c, c.visit(b=resource))
#t = expovariate(1.0 / meanTBA)
t = 10.0
yield hold, self, t

class Customer(Process):
""" Customer arrives, is served and leaves """

def visit(self, b):
leavelist = [] /* Name of List defined */
arrive = now()
#tib = expovariate(1.0 / timeInBank)
tib = timeInBank
/* Console Output results start here */
print("%8.3f %s: Here I am" % (now()/60, self.name))
yield (request, self, b), (hold, self,maxWaitTime)
wait = now() - arrive
if self.acquired(b):
print("%8.3f %s: Waited %6.3f" % (now()/60, self.name, wait))
yield hold, self, tib
yield release, self, b
print("%8.3f %s: Finished" % (now()/60, self.name))
else:
print("%8.3f %s: Waited too long %6.3f" % (now()/60, self.name, wait) + " time units have passed - Customer has left")
leavelist.append(self.acquired)
print len(leavelist)

What I am looking to do is the "customers" who have "Waited too long" get added to my leavelist() as they occur.

Does this make sense?

Thank you.
.



Relevant Pages

  • Re: First attempt at a Python prog (Chess)
    ... EMPTY = 0 ... def display_board: ... In Python 2 you can get this effect by using: ... yield board ...
    (comp.lang.python)
  • Re: mimic File.open pattern
    ... irb:001:0> class Resource ... irb:003:1> def initialize ... you can make it more efficient if your use `yield' instead of calling the block explicitly: ...
    (comp.lang.ruby)
  • Re: Just for fun: Countdown numbers game solver
    ... Ops is vanilla, cleverops only returns canonical expressions as defined in Dan's email. ... def getop: return 'n' if isinstance ... yield x + y, ... "Return all ways of reaching target with nums" ...
    (comp.lang.python)
  • First attempt at a Python prog (Chess)
    ... def display_board: ... def piece_moves(board, index, dx, dy, capture_flag, distance): ... yield board ...
    (comp.lang.python)
  • Algorithm for generating pitch-class sets in prime form
    ... An easy way of finding a prime form in Python is: ... def prime_form: ... yield perm ... from the end, permute the rest, and replace it on the end of each permutation: ...
    (comp.lang.python)