469,602 Members | 1,751 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,602 developers. It's quick & easy.

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(event, 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(event,TickEvent):...?

Oct 26 '06 #1
4 1038
steve wrote:
The example code from: http://sjbrown.ezide.com/games/example1.py.html
...
def Notify( self, event ):
if not isinstance(event, 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(event,TickEvent):...?
no, that line simply checks if it's a specific Event type, and enables
debug logging for all other event types.

</F>

Oct 26 '06 #2
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(event, 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(event,TickEvent):...?

no, that line simply checks if it's a specific Event type, and enables
debug logging for all other event types.

</F>
Oct 27 '06 #3
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>

Oct 27 '06 #4
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>
Oct 28 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Robert | last post: by
4 posts views Thread by rawCoder | last post: by
8 posts views Thread by Donald Xie | last post: by
4 posts views Thread by AzizMandar | last post: by
24 posts views Thread by =?Utf-8?B?U3dhcHB5?= | last post: by
2 posts views Thread by =?Utf-8?B?U2F2dm91bGlkaXMgSW9yZGFuaXM=?= | last post: by
reply views Thread by guiromero | last post: by
reply views Thread by devrayhaan | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.