[Python] Disable automatic printing in Python interactive session

Discussão em 'Python' iniciado por Stack, Setembro 14, 2025.

  1. Stack

    Stack Membro Participativo

    I am looking for a way to modify the default behavior of Python interactive sessions so that expressions do not automatically print out results. For example, take this following interactive session:

    ~$ python
    Python 2.7.3 (default, Aug 1 2012, 05:16:07)
    [GCC 4.6.3] on linux2
    Type "help", "copyright", "credits" or "license" for more information.
    >>> x = 5
    >>> y = 7
    >>> x + y
    12
    >>> first_name = "Test"
    >>> last_name = "Person"
    >>> first_name + last_name
    'TestPerson'


    This would enforce using the print statement to avoid confusion later on. I was unable to find settings for this.

    I can preconfigure the machine beforehand, so any solutions work. Is this possible, or what change to the interactive sessions creates this effect?

    Continue reading...

Compartilhe esta Página