inelegance in calling dynamically created class methods from scripting level

Andrew Durdin adurdin at gmail.com
Thu Sep 23 21:05:58 EDT 2004


On Wed, 22 Sep 2004 17:21:16 -0600, Danny Shevitz <shevitz at lanl.gov> wrote:
> # ds.myApply(???something callable???) Can't get to work!

You need to be able to reference the callable via some name in the
current scope. For 'myPrint' that's easy:
    ds.myApply(Item.myPrint)

For 'hoopty', you can't do that, because in the current scope you
don't have a name bound to any object with the 'hoopty' attribute. But
since you know that the hoopty attribute was bound to the reset
function, you can get the desired effect like this:
    ds.myApply(reset)



More information about the Python-list mailing list