[Tutor] Accessing Functions By Reference
Lloyd Kvam
pythonTutor at venix.com
Thu Oct 21 17:23:42 CEST 2004
somefunction is a reference to the function
somefunction() calls the function.
a = somefunction # binds the name a to the function
a() # calls the function
I've usually seen the ability to process functions using variables (i.e.
just another form of data) described as having "first class functions".
On Thu, 2004-10-21 at 11:05, Gooch, John wrote:
> Is it possible to access a function by reference? I.e. it's address in
> memory? What I would like to do it pass in a reference to a function when
> creating an instance of a class, so that the class can make use of that
> function via that reference.
>
> e.g. def somefunction( blah ):
> do something with blah
> return something
>
> myclass = SomeClass( <reference to somefunction> )
> print str( myclass.referenceToSomeFunction( someValue ) )
>
>
>
>
> John A. Gooch
> Systems Administrator
> IT - Tools
> EchoStar Satellite L.L.C.
> 9601 S. Meridian Blvd.
> Englewood, CO 80112
> Desk: 720-514-5708
> _______________________________________________
> Tutor maillist - Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
--
Lloyd Kvam
Venix Corp
More information about the Tutor
mailing list