Ask Your Question

can I use @interact also with the command line?

asked 2022-01-23 11:02:34 +0200

dantetante gravatar image

updated 2022-01-23 11:07:56 +0200

I understand that @interact is to be used inside of Jupyter. But since I like the command line much more, I'd like to know if there are ways to use it from a) the SageMath Console in Windows and b) Terminal on Mac OS X also.

edit retag flag offensive close merge delete


Not sure whether nbterm could help with that, but maybe worth a look.

slelievre gravatar imageslelievre ( 2022-01-23 12:52:39 +0200 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2022-01-23 14:12:43 +0200

Emmanuel Charpentier gravatar image

Short (unusable) answer : no.

Better answer : @interact wraps your function in an interact call ; interact ... interacts (surprise !) with an underlying notebook infrastructure running your interface when this infrastructure exists !. If you are running from the command line, this infrastructure does not exists, and interact has nothing to interact with.

In fact, typing interact? in a notebook cell gets you the documentation of the Interact class,which is the infrastructure needed for such interactions. But in a command line session :

sage: interact?
Object `interact` not found.

the interact function isn't even defined then.

Without looking at the source code, one can guess that the Interact class and its companions are defined at session startup ... if and only if the needed infrastructure exists in the session.


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

1 follower


Asked: 2022-01-23 11:02:34 +0200

Seen: 208 times

Last updated: Jan 23 '22