inelegance in calling dynamically created class methods from scripting level
Marc Christiansen
tolot at jupiter.solar-empire.de
Fri Sep 24 05:31:07 EDT 2004
Andrew Durdin <adurdin at gmail.com> wrote:
> 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)
Well, one could use
ds.myApply(ds.childClass.hoopty)
but this looks strange to me. It asks me: "Do I really want this
approach?".
Marc
More information about the Python-list
mailing list