繁体   English   中英

python sage从命令行附加并运行另一个命令

[英]python sage attach from command line and run another command

我想加载一个鼠尾草文件并从该文件运行功能,所有这些都来自bash。

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

如何使它正常工作,或者我该怎么办?

如果可以帮助某人...

我最终使用了这种怪物:

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

好的, rm部分实际上并不需要全部:)

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM