"Shrutarshi Basu" <[EMAIL PROTECTED]> wrote

  def parse_display(self ):

      try:
          gram = Grammars(10, 10, self.pc_map, self.hard_rules)
          gram.database = {}

How is gram.database defined? Is it an instance attribue or
a class attribute? If you have

class Grammars:
    database = {}
    def __init__(....): ....

instead of

class Grammars:
    def __init__(....):
         self.database = {}
          ....

Then database will be shared by all instances of Grammars

BTW Its conventional to name classes in the singular unless
it genuinely represents a collection of some sort. I can't tell
if thats the case here, but it seems more likely that it
represents a specific Grammar?

As you can see, not only do I delete gram, I also blank out everything that should be cleared. I have to manually clear gram.database because
otherwise it keeps the data from previous calls to that function. I
don't understand why this should be. DisplayModule is a class that
packages and organizes the data into a convenient form.

If its a class variable then deleting the instance will have no affect.

About all I can think of without seeing more code.

Alan G.

_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to