【问题标题】:python sage attach from command line and run another commandpython sage 从命令行附加并运行另一个命令
【发布时间】:2013-10-13 11:35:08
【问题描述】:

我想从 bash 加载一个 sage 文件并从该文件运行一个函数。

attach 命令给我带来了麻烦...

这行得通:

bash-prompt$ sage -c "print 2; print 3"
2
3
bash-prompt$

这也有效:

bash-prompt$ sage -c "attach somefile.sage"
some print just to confirm the file is loaded
bash-prompt$

但这不起作用:

bash-prompt$ sage -c "attach somefile.sage; print 3"
python: can't open file '/path/to/somefile.sage; print Integer(3)': [Errno 2] No such file or directory

我怎样才能让它工作,或者我能做些什么?

【问题讨论】:

    标签: command-line sage


    【解决方案1】:

    如果它对某人有帮助...

    我最终使用了这个怪物:

    sage somefile.sage && sage -python -c "execfile('somefile.py'); wrapper()" && rm somefile.py
    

    好的,rm 部分并不是真正需要的 :)

    【讨论】:

      【解决方案2】:

      我认为最简单的做法是将函数作为实际 Sage 文件的最后一行调用:例如,“somefile.sage”的最后一行将是 print 3。

      【讨论】:

        猜你喜欢
        • 2022-01-24
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多