• Python allowing future procedures declared, when was this change?

    From Blaine@3:633/10 to All on Tue Nov 10 16:57:15 2026
    I wrote some stuff and had a future procedure referenced. It worked
    great. Wasn't it up to very recently that Python procedures had to be
    defined before use, not following?
    --
    Hits like a Phillips head into my brain
    It's gonna be too dark to sleep again
    Cutting my teeth on bars and rusty chains
    I'm gonna break my rusty cage And run

    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Paul Rubin@3:633/10 to All on Tue Nov 10 16:29:27 2026
    Blaine <cactus_DAC@yahoo.com> writes:
    I wrote some stuff and had a future procedure referenced. It worked
    great. Wasn't it up to very recently that Python procedures had to be
    defined before use, not following?

    You can have forward references at compile time, but the target
    procedure has to be defined before you can execute it. That is,

    def a():
    b()

    def b():
    print('hi')

    a()

    works fine. Python is interpreted and "def" is an executable statement, actually a type of assignment statement. So by the time you call a(),
    the "def b():" has actually run, so you can call b.

    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Blaine@3:633/10 to All on Tue Nov 10 18:12:42 2026
    Paul Rubin wrote:
    Blaine <cactus_DAC@yahoo.com> writes:
    I wrote some stuff and had a future procedure referenced. It worked
    great. Wasn't it up to very recently that Python procedures had to be
    defined before use, not following?

    You can have forward references at compile time, but the target
    procedure has to be defined before you can execute it. That is,

    def a():
    b()

    def b():
    print('hi')

    a()

    works fine. Python is interpreted and "def" is an executable statement, actually a type of assignment statement. So by the time you call a(),
    the "def b():" has actually run, so you can call b.

    Ok, so I was probably doing something like this instead before:

    def a():
    b()

    a()

    def b():
    print('hi')

    Is that what you mean?

    That indeed gives an error. I probably was doing something similar
    before and didn't realize it. This will be useful.
    --
    Hits like a Phillips head into my brain
    It's gonna be too dark to sleep again
    Cutting my teeth on bars and rusty chains
    I'm gonna break my rusty cage And run

    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Paul Rubin@3:633/10 to All on Tue Nov 10 19:39:41 2026
    Blaine <cactus_DAC@yahoo.com> writes:
    a()
    def b(): ...
    Is that what you mean?

    Yes, that's probably what happened. b is undefined until "def b():" runs.

    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)