Re: Using my routines as functions AND methods

[email protected] (Stefan Ram)
Newsgroups comp.lang.python
Organization Stefan Ram
Message-ID <[email protected]>
Thomas Passin <[email protected]> writes:
>def convert_method(f):

  You guys could also check out "MethodType" from "types".

from types import *

def f():
    pass

f.i = 0

def inc( f ):
    f.i +=  1

f.inc = MethodType( inc, f )

f.inc()

print( f.i )

  .
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.