[IronPython] Method invocation when assigned to instancediffers from default assignment?

Erzengel des Lichtes erzengel-von-licht at cox.net
Sun Feb 18 01:42:36 PST 2007


 

-----Original Message-----
From: users-bounces at lists.ironpython.com
[mailto:users-bounces at lists.ironpython.com] On Behalf Of drew moore
Sent: Saturday, February 17, 2007 1:07 PM
To: Discussion of IronPython
Subject: Re: [IronPython] Method invocation when assigned to instancediffers
from default assignment?

Your question might not seem so silly (sorry) if we can see the problem you
are trying to solve.

--Reply--
I'm not actually trying to solve a problem, just understand a behavior.

Because I'm replacing portions of IronPython to allow me to interrupt a
script at any point (and save local variables and the instruction pointer),
I have to reimplement code. Originally I had classes running the code under
the class scope on every instance (I thought it was like C# where class
assignments are basically added to all constructors); then it was noticed
that in instances where the class code ran a function this was a variation
in the behavior of IronPython /w Fibers vs. Interuptable IronPython. I
realized my mistake, fixed it, and the unit test case included not only
assigning variables and running functions (which was used in the python
scripts we've already made), but assigning functions--both to the class and
the instance. Again it had a variation (Our Interruptable didn't see the
extra variable, IronPython complained), as I was assuming that any
assignment of a function would assign the function type instead of a
bound/unbound method on class types. After all, changing a variable on the
class only changed the referance, not the type. This lead to the E-mail, as
I didn't understand what exactly was going on here. It seems to be somewhat
inconsistent.
So I don't actually have a problem needing a solution, just a "Why is it
that way?" sort of question.
At the moment, I'm having difficulty visualizing a real world scenario where
this capability would be useful; it just happened to be a part of the
testing scenarios to ensure consistent behavior. If it were like an event,
would it not be preferable to be able to have a "default event" that can be
overriden with an "instance event"? Otherwise, why have instance functions
at all?

Thanks for info,

Erzengel des Lichtes
Hikari no Daitenshi
Archangel of Light




More information about the users mailing list