On Mar 24, 2012, at 11:31 , tvn wrote:

> This seems to be a very weird behavior.  After modifying a file,  all 
> instantiated instances V of classes C in the file are no longer correct 
> (i.e. instance(V,C)  returns false).   
> 
> Here's a simple example illustrating the problem  
[snip]
> Now go back to the file t1.py,  make any modification ,  e.g.  enter a 
> space and delete it ... save the file
> 
> sage: isinstance(t,Test)
> False   ####  here it's no longer correct

While it seems wrong/weird, I think it actually makes sense.  The root of 
problem is that the explanation lies in the implementation details.  The 
following is a rough sketch; the details are, well, details :-}

To test whether something is an instance of a type, you have to have a 
specification for the type.  When you modified the file that you previously 
attached, it was reloaded, and that action removed the old version and added 
the new version.  The way types are maintained internally causes the 
"isinstance()" check to fail because, in fact, the old instance is not of the 
new type.

Keep in mind that the internal code is not going to try to figure out that a 
newly-loaded version is different from the previous version; it's just "out 
with the old; in with the new".

When I'm in the middle of the "Edit/Reload/Debug" loop, I have to make sure I 
redefine all the gizmos associated with the files I'm editing.  Otherwise, 
strange and wondrous things happen.

If I have this wrong, I think someone will speak up, but that's Truth as I 
understand it.

HTH

Justin

--
Justin C. Walker, Curmudgeon-At-Large
Institute for the Enhancement of the Director's Income
--------
When LuteFisk is outlawed,
Only outlaws will have LuteFisk
--------



-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org

Reply via email to