[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] Initializing and Reinitializing Instance variables



mspaintmaestro@xxxxxxxxx wrote:
class ApplicationContext:
  def __init__(self):
    self.session = GameSession()

  def reset(self):
    self.session = GameSession()

Nope, this doesn't solve your fundamental problem of getting rid of a duplicate assignment,

I'd probably do it like this:

  class ApplicationContext:

    def __init__(self):
      self.session = None
      reset()

    def reset(self):
      self.session = GameSession()

--
Greg