How the event list be sent to EventManager?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • steve

    #1

    How the event list be sent to EventManager?

    The example code from: http://sjbrown.ezide.com/games/example1.py.html
    ....
    def Notify( self, event ):
    if not isinstance(even t, TickEvent): Debug( "
    Message: " + event.name )
    for listener in self.listeners. keys():
    #If the weakref has died, remove it and
    continue
    #through the list
    if listener is None:
    del self.listeners[ listener ]
    continue
    listener.Notify ( event )

    I can not figure out how 'event' can has reference to 'event.name'?
    Anyhow the 'event' has not defined!
    The 'event' dynamically get its own type through
    isinstance(even t,TickEvent):.. .?

  • Fredrik Lundh

    #2
    Re: How the event list be sent to EventManager?

    steve wrote:
    The example code from: http://sjbrown.ezide.com/games/example1.py.html
    ...
    def Notify( self, event ):
    if not isinstance(even t, TickEvent): Debug( "
    Message: " + event.name )
    for listener in self.listeners. keys():
    #If the weakref has died, remove it and
    continue
    #through the list
    if listener is None:
    del self.listeners[ listener ]
    continue
    listener.Notify ( event )
    >
    I can not figure out how 'event' can has reference to 'event.name'?
    because the developer expects you to pass in an object that has a name
    attribute ? (one of the Event types defined at the top of that module,
    most likely).
    Anyhow the 'event' has not defined!
    it's an argument to the method.
    The 'event' dynamically get its own type through
    isinstance(even t,TickEvent):.. .?
    no, that line simply checks if it's a specific Event type, and enables
    debug logging for all other event types.

    </F>

    Comment

    • steve

      #3
      Re: How the event list be sent to EventManager?

      Can an argument to reference an object's attribute??

      Fredrik Lundh wrote:
      steve wrote:
      >
      The example code from: http://sjbrown.ezide.com/games/example1.py.html
      ...
      def Notify( self, event ):
      if not isinstance(even t, TickEvent): Debug( "
      Message: " + event.name )
      for listener in self.listeners. keys():
      #If the weakref has died, remove it and
      continue
      #through the list
      if listener is None:
      del self.listeners[ listener ]
      continue
      listener.Notify ( event )

      I can not figure out how 'event' can has reference to 'event.name'?
      >
      because the developer expects you to pass in an object that has a name
      attribute ? (one of the Event types defined at the top of that module,
      most likely).
      >
      Anyhow the 'event' has not defined!
      >
      it's an argument to the method.
      >
      The 'event' dynamically get its own type through
      isinstance(even t,TickEvent):.. .?
      >
      no, that line simply checks if it's a specific Event type, and enables
      debug logging for all other event types.
      >
      </F>

      Comment

      • Fredrik Lundh

        #4
        Re: How the event list be sent to EventManager?

        steve wrote:
        Can an argument to reference an object's attribute??
        sorry, cannot parse that sentence.

        the arguments to a method are objects, and objects have attributes. why
        do you find this surprising?

        </F>

        Comment

        • steve

          #5
          Re: How the event list be sent to EventManager?

          Thank you,Fredrik,I see.

          Fredrik Lundh wrote:
          steve wrote:
          >
          Can an argument to reference an object's attribute??
          >
          sorry, cannot parse that sentence.
          >
          the arguments to a method are objects, and objects have attributes. why
          do you find this surprising?
          >
          </F>

          Comment

          Working...