• Seeing Variables

    From Stefan Ram@3:633/280.2 to All on Wed Jun 11 20:30:42 2025
    Did you know that after your program has terminated in IDLE,
    you still can see the variables in the shell?

    For example:

    IDLE editor

    a = 1 (user input)

    [F5] - run (user input)

    IDLE shell

    a (user input)
    1 (system output)

    But how to achieve the same for local variables? E.g.,

    IDLE editor

    def f(): (user input)
    a = 1 (user input)

    IDLE shell

    a (user input)
    NameError: name 'a' is not defined (system output)



    --- MBSE BBS v1.1.1 (Linux-x86_64)
    * Origin: Stefan Ram (3:633/280.2@fidonet)
  • From Stefan Ram@3:633/280.2 to All on Thu Jun 12 18:59:58 2025
    ram@zedat.fu-berlin.de (Stefan Ram) wrote or quoted:
    But how to achieve the same for local variables?

    import pdb

    def f():
    a = 1
    pdb.set_trace()

    f()

    . Now, the program stops there and you can enter:

    print( a ) (user input)
    1 (system output)

    . However, it's a bit more difficult than it could be -
    especially for beginners - due to the cryptic names chosen!
    One could more easily remember something like:

    import debug

    def f():
    a = 1
    debug.stop()

    f()

    . When a method is named "set_trace", some people might think
    its purpose is to set a property called "trace". Moreover, it's
    not obvious how invoking an interactive debug session should bring
    up the idea of "setting a trace", what does that even mean??



    --- MBSE BBS v1.1.1 (Linux-x86_64)
    * Origin: Stefan Ram (3:633/280.2@fidonet)
  • From Paul Rubin@3:633/280.2 to All on Thu Jun 12 19:35:02 2025
    ram@zedat.fu-berlin.de (Stefan Ram) writes:
    . When a method is named "set_trace", some people might think
    its purpose is to set a property called "trace".

    In Py3 you can use breakpoint()

    --- MBSE BBS v1.1.1 (Linux-x86_64)
    * Origin: A noiseless patient Spider (3:633/280.2@fidonet)