function prototyping?
Duncan Booth
duncan.booth at invalid.invalid
Thu Apr 13 13:58:56 EDT 2006
Burton Samograd wrote:
> Is there any way to 'prototype' functions in python, as you would in
> C? Would that be what the 'global' keyword is for, or is there a more
> elegant or 'pythonic' way of doing forward references?
>
There isn't really such a thing as a forward reference in Python. Always
remember that 'def' and 'class' are executable statements:
def a():
b()
def b():
print "b called"
a()
So long as you have executed both def statements before you call the first
function it will find the second one. In the example above, if you called
a() before executing 'def b()' the function 'b' wouldn't exist so you
couldn't call it.
More information about the Python-list
mailing list