why is there no class (static) methods in Python ?

Bjorn Pettersen BPettersen at NAREX.com
Mon Jun 18 16:08:21 EDT 2001


> From: D-Man [mailto:dsh8290 at rit.edu]
> 
> On Mon, Jun 18, 2001 at 12:21:53PM -0700, James_Althoff at i2.com wrote:
> <...>
> | I notice that yourModule.yourFunction1
> | is exactly what I want, but I need to override 
> yourModule.yourFunction2 in
> | order to adapt it for myModule.MyClass.  How can I do this 
> (preferably
> | WITHOUT resorting to "black magic" and whilst preserving
> | "thread-safeness")?
> 
> #### myModule.py
> 
> import yourModule
> 
> myFunction1 = yourModule.yourFunction1
> 
> def myFunction2( ) :
>     pass

Doesn't work:

d:\>type A.py

def fun1():
        fun2()

def fun2():
        print 'A.fun2()'


d:\>type B.py

import A

fun1 = A.fun1

def fun2():
        print 'B.fun2()'

fun1()

d:\>python B.py
A.fun2()

d:\>

-- bjorn




More information about the Python-list mailing list