[Edu-sig] Design Pattern question

Simon Burton simon at arrowtheory.com
Sun Oct 19 20:50:44 EDT 2003


>
>I wondered if anyone had ideas about a design pattern I've been playing
>with.  Is it perverse?
>

No, it seems reasonable enough.

I sometimes use an Id class with a "next_id":

class Id:
  next_id = 0
  def __init__(self):
    self.id = Id.next_id
    Id.next_id += 1

and then inherit from Id wherever i need unique (small) id's.

Your idea is rather more funky, but what else are class
variables for?

Simon Burton.

 



More information about the Edu-sig mailing list