function pointers

Max Møller Rasmussen maxm at normik.dk
Thu Apr 26 05:55:38 EDT 2001


> From: Brandon J. Van Every [mailto:vanevery at 3DProgrammer.com]

> I get the feeling that Python doesn't have anything 
> resembling a function
> pointer?  i.e. no way to call a specific function according 
> to the value a
> variable is set to?

Might this be what you are looking for?

def hello():
	return 'hello'

def world():
    return 'world'

functions = {}
functions['hll'] = hello
functions['wrld'] = world

print functions['hll']()
print functions['wrld']()

regards Max M




More information about the Python-list mailing list