Ask Your Question
0

%attach misc.sage; a bug?

asked 2013-11-02 14:40:59 +0100

fidbc gravatar image

Hi!

I'm running sage 5.11 on linux. I have a file called misc.sage which %attach seems to not like very much. The problem seems to be the filename, since even an empty file or just a print statement in it produce the same reaction. Is this a bug? Is this present in 5.12 too?

sage: %attach misc.sage                                                                                                                                                                    [2/708]
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-22-239b268dc29e> in <module>()
----> 1 get_ipython().magic(u'attach misc.sage')

/home/fidbc/._sys/opt/sage-5.11/local/lib/python2.7/site-packages/IPython/core/interactiveshell.pyc in magic(self, arg_s)
   2134         magic_name, _, magic_arg_s = arg_s.partition(' ')
   2135         magic_name = magic_name.lstrip(prefilter.ESC_MAGIC)
-> 2136         return self.run_line_magic(magic_name, magic_arg_s)
   2137
   2138     #-------------------------------------------------------------------------

/home/fidbc/._sys/opt/sage-5.11/local/lib/python2.7/site-packages/IPython/core/interactiveshell.pyc in run_line_magic(self, magic_name, line)
   2060                 args.append(sys._getframe(stack_depth).f_locals)
   2061             with self.builtin_trap:
-> 2062                 result = fn(*args)
   2063             return result
   2064

/home/fidbc/._sys/opt/sage-5.11/local/lib/python2.7/site-packages/sage/misc/sage_extension.pyc in attach(self, s)

/home/fidbc/._sys/opt/sage-5.11/local/lib/python2.7/site-packages/IPython/core/magic.pyc in <lambda>(f, *a, **k)
    189     # but it's overkill for just that one bit of state.
    190     def magic_deco(arg):
--> 191         call = lambda f, *a, **k: f(*a, **k)
    192
    193         if callable(arg):

/home/fidbc/._sys/opt/sage-5.11/local/lib/python2.7/site-packages/sage/misc/sage_extension.pyc in attach(self, s)
    118         """
    119         from sage.misc.preparser import load_wrap
--> 120         return self.shell.ex(load_wrap(s, attach=True))
    121
    122     @line_magic

/home/fidbc/._sys/opt/sage-5.11/local/lib/python2.7/site-packages/IPython/core/interactiveshell.pyc in ex(self, cmd)
   2378         """Execute a normal python statement in user namespace."""
   2379         with self.builtin_trap:
-> 2380             exec cmd in self.user_global_ns, self.user_ns
   2381
   2382     def ev(self, expr):

<string> in <module>()

/home/fidbc/._sys/opt/sage-5.11/local/lib/python2.7/site-packages/sage/misc/preparser.pyc in load(filename, globals, attach)
   1721                 return
   1722
-> 1723     filename = filename.strip()
   1724
   1725     if filename.lower().startswith(('http://', 'https://')):

AttributeError: 'module' object has no attribute 'strip'
edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
1

answered 2013-11-02 15:25:47 +0100

Try using quotes: %attach 'misc.sage'. Without quotes, misc is interpreted as being a module within Sage -- for example, type just misc.sage from the sage: prompt.

edit flag offensive delete link more

Comments

Thank you!

fidbc gravatar imagefidbc ( 2013-11-02 15:27:42 +0100 )edit
1

answered 2013-11-02 15:39:43 +0100

tmonteil gravatar image

It also works with absolute path:

sage: %attach /tmp/misc.sage
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2013-11-02 14:40:59 +0100

Seen: 378 times

Last updated: Nov 02 '13