Pointing to function from class

Janko Hauser jhauser at ifm.uni-kiel.de
Tue Oct 17 03:26:21 EDT 2000


If your goal is to call a class function from the outside, you can do
it the other way araound, namely generate an unbound function.

class base:
    def SomeFunc(self):
        print 'Here'

f = base().SomeFunc
f()

HTH,
__Janko    

Adam Clark <bjrubble at shell16.ba.best.com> writes:

> Hi.
> 
> I want something like this:
> 
> def SomeFunc () :
>   # doesn't take self and can be called from outside a class
> 
> class Class :
>   f = SomeFunc
> 
> c = Class()
> c.f()
> 
> I can't keep the class from trying to bind the function.
> 
> Help!
> Thanks
> Adam

-- 
  Institut fuer Meereskunde             phone: 49-431-597 3989
  Dept. Theoretical Oceanography        fax  : 49-431-565876
  Duesternbrooker Weg 20                email: jhauser at ifm.uni-kiel.de
  24105 Kiel, Germany



More information about the Python-list mailing list