Function declarations

Samuel A. Falvo II kc5tja at garnet.armored.net
Sat Nov 18 16:30:24 EST 2000


On Sat, 18 Nov 2000 20:23:36 -0000, Makhno wrote:
>Is it possible to obtain a reference to a function before it has been
>'def'ined?

You could do something like this:

# at global scope:

def GetFunc1Reference():
  return Func1
  
# ... other code ...

def Func1( .. ):
  pass

REF_TO_FUNC1 = GetFunc1Reference()

# ... other code ...

REF_TO_FUNC1()

This technique can be used inside a class too.

>I find Python's "def is an executable statement" very irritating...

That's the nature of an interactive programming language.

-- 
KC5TJA/6, DM13, QRP-L #1447 | Official Channel Saint, *Team Amiga*
Samuel A. Falvo II	    |
Oceanside, CA		    |



More information about the Python-list mailing list