# Collection of code snippets by Arne Vajhøj 
# (from articles on eksperten.dk / vajhoej.dk written sometime between 2004 and now) 
import clr
clr.AddReference("DN")

from m2m import IAction
from m2m import DN

class PyAction(IAction):
    __namespace__ = "pym2m" # necessary to avoid a weird error
    def __init__(self, _iv, _sv):
        self.iv = _iv
        self.sv = _sv
    def M(self):
        self.iv = self.iv + 1
        self.sv = self.sv + "X"
        return
    def __str__(self):
        return '{%s,%s}' % (self.iv, self.sv)

o = PyAction(123, "ABC")
DN.Demo(3, "Hi", o)
print(o.__str__()) # not sure why explicit call is needed
