ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Thu, 09 Aug 2012 16:18:57 +0200Sage is not updating modules imported by an attached filehttps://ask.sagemath.org/question/9221/sage-is-not-updating-modules-imported-by-an-attached-file/My file structure looks like:
<pre>
project/
__init__.py
project.py
bounds.py
</pre>
project.py looks approximately like:
<pre>
import sys
import os
import bounds
def myfunction(g):
if has_bound(g):
...
def has_bound(g):
lbound = 1
for name, obj in inspect.getmembers(bounds, inspect.isclass):
if obj.__module__ == 'bounds':
new_bound = obj.bound(g)
if new_bound > lbound:
lbound = new_bound
return lbound
</pre>
bounds.py:
<pre>
import abc
class BoundBase(object):
@staticmethod
@abc.abstractmethod
def bound(g):
return
class SpecificBound(LowerBoundBase):
@staticmethod
def bound(g):
return 5
</pre>
Now, I start a Sage session in the Terminal and do <code>attach project.py</code>. I can even make changes in project.py and see the results immediately in Sage. The problem is that if I change something in bounds.py, Sage won't pick up on the changes. I've tried combinations of reset(), detach(), attach(), load(), but the only thing that works is quitting Sage completely and restarting it. There must be a better way!patronicsThu, 09 Aug 2012 16:18:57 +0200https://ask.sagemath.org/question/9221/