calling class instances and their methods

Erik Johnson nobody at invalid.com
Mon Mar 26 11:57:20 EDT 2007


"spohle" <spohle at gmail.com> wrote in message
news:1174921229.208577.8290 at e65g2000hsc.googlegroups.com...
> hi,
>
> i created an instance of a my own class which has methods and all. now
> i get an outside function called, which is unfortunatly not aware of
> the instace at all (i don't control how this outside function is
> called). but i would like to get access back to my instance and it's
> methods.
>
> is there any clean way of doing this ?
>
> thanks in advance


Ummm...  I'm not exactly sure what you mean by "an outside function", but
let's refer to that function as f(). Are you saying you want to re-implement
f() to use your new object but don't want to (or can't) change calls to f()?

    If so, then you can either use a global reference to your new object if
it is the sort of thing you want to keep around between invocations of f()
(i.e., create your object somewhere and then save in a scope that f() can
access). Otherwise, you can simply instantiate your object inside of f() as
a local variable and use it.

    If you mean something else, I guess you will have to clarify.





More information about the Python-list mailing list