Menu

Behave like normal python console

Help
2017-09-06
2017-09-06
  • Joerg Kreuzberger

    Hi!

    I tried the gui example for console and made some modifications. Works well, redirection of input, output of python works
    The main difference is the REPL (read, eval, print) behaviour.
    in a normal shell typing e.g. a normal variable will print the value, or if i call 10+10 the result is printed. In the example if have to explicit call print()

    Does anybody know how to print out the last result like in normal python console?

     
  • Florian Link

    Florian Link - 2017-09-06

    The evaluation of Python code only returns a value if used in single line parsing mode, there is an enum for that. The call will then return the value as QVariant, which you can print with Qt.

     
  • Joerg Kreuzberger

    It is even better: the python does it automatically. It creates a "_" variable and prints the value via normal stdout. Nothing to implement. Extra impl would be necessary if you want to do something like the ipython console, but this is not required for us.
    Thanks

     

    Last edit: Joerg Kreuzberger 2017-09-07

Log in to post a comment.