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

    From Blaine@cactus_DAC@yahoo.com to comp.lang.python on Tue Nov 10 16:57:15 2026
    From Newsgroup: comp.lang.python

    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
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Paul Rubin@no.email@nospam.invalid to comp.lang.python on Tue Nov 10 16:29:27 2026
    From Newsgroup: comp.lang.python

    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.
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Blaine@cactus_DAC@yahoo.com to comp.lang.python on Tue Nov 10 18:12:42 2026
    From Newsgroup: comp.lang.python

    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
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Paul Rubin@no.email@nospam.invalid to comp.lang.python on Tue Nov 10 19:39:41 2026
    From Newsgroup: comp.lang.python

    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.
    --- Synchronet 3.22a-Linux NewsLink 1.2