Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

REPL behaviour in MayaSublime #35

Open
ESNV opened this issue Jan 27, 2019 · 1 comment
Open

REPL behaviour in MayaSublime #35

ESNV opened this issue Jan 27, 2019 · 1 comment

Comments

@ESNV
Copy link

ESNV commented Jan 27, 2019

Hi,

Would it be possible to mimic in MayaSublime some of the REPL that exists in Maya's Script Editor?

For example, after first executing an assignment:
foo = 'bar'
then by highlighting and running only the "foo" part get:
'bar'
as the output/result, instead of having to do:
print(foo)

Cheers!
Lalo.

@justinfx
Copy link
Owner

Sure. This can probably be implemented by using python's ast module, and parsing the selected code to see if its a single expression:

import ast

# ok: Wrap it in a   print (text)
ast.parse('x+1', mode='eval')

# not expression: raises exception
ast.parse('x=x+1', mode='eval')
SyntaxError: invalid syntax

# not expression: raises exception
ast.parse('x=0; x+=1; print x', mode='eval')
SyntaxError: invalid syntax

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants