🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: comp.lang.python
4 messages
4 total messages Started by Blaine Tue, 10 Nov 2026 23:57
Python allowing future procedures declared, when was this change?
#210
Author: Blaine
Date: Tue, 10 Nov 2026 23:57
8 lines
1604 bytes
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
Re: Python allowing future procedures declared, when was this change?
#211
Author: Paul Rubin
Date: Wed, 11 Nov 2026 00:29
19 lines
1786 bytes
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.
Re: Python allowing future procedures declared, when was this change?
#212
Author: Blaine
Date: Wed, 11 Nov 2026 01:12
40 lines
2486 bytes
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
Re: Python allowing future procedures declared, when was this change?
#213
Author: Paul Rubin
Date: Wed, 11 Nov 2026 03:39
6 lines
1400 bytes
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.
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads