From: Dzhelil R. <dz...@gm...> - 2008-09-12 08:48:55
|
Hello, I am trying to override the __str__ and __repr__ functions of a C struct that has been imported into python using swig. Doing it the usual way : import swig_module Path (swig_module.Path): def __init__(self): def __str__(self): def __repr__(self): i expected it to work like most other native python modules, but whenever I print it I don't get the desired results: > path = Path() > print str(path) <swig_module.Path; proxy of <Swig Object of type 'Path *' at 0x316f40> Apparently the swig string representation does not get overwritten. What am I doing wrong? I have cheked that the swig version is really a subclass, so it must have its methods overriden, doesn't it? > issubclass(Path, swig_module.Path) True Thanks D |