[Tutor] Problem with SWIG and Shadow Classes

Marcus Konermann m_konermann@gmx.de
Thu, 22 Nov 2001 15:30:06 +0100


--------------010708010408010104060307
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit

Hi !

I`ve got a python module, generated with SWIG, named simannealfile.py . 
It is beginning like the following:

# This file was created automatically by SWIG.
import simannealfilec
class simanneal_varlist:
    def __init__(self,*args):
        self.this = apply(simannealfilec.new_simanneal_varlist,args)
        self.thisown = 1

    def __del__(self,simannealfilec=simannealfilec):
        if getattr(self,'thisown',0):
            simannealfilec.delete_simanneal_varlist(self)
...

I imported this File in another Module named mainko.py :

import string,re,sys,glob,operator
import simannealfile


instance1=simannealfile.simulated_annealing()

fx=instance1.optimize()

print 'test=',fx

The mainko.py file is just a dummy to test teh correct function, but 
after executing the following output appers:

Traceback (most recent call last):
  File "c:\programme\python21\pythonwin\pywin\framework\scriptutils.py", 
line 396, in ImportFile
    reload(sys.modules[modName])
  File "C:\Arbeit_Diplomarbeit\__Optimierer\ext1\mainko.py", line 2, in ?
    import simannealfile
  File "C:\Arbeit_Diplomarbeit\__Optimierer\ext1\simannealfile.py", line 
2, in ?
    import simannealfilec
ImportError: No module named simannealfilec

Python seems to have problems finding the file simannealfilec .This file 
is automatically generated by the SWIG Wrapper an no visible.
So, it would be very good, if anyone has got a solution to my problem.

Greetings
Marcus






--------------010708010408010104060307
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit

<html>
<head>
</head>
<body>
Hi !<br>
<br>
I`ve got a python module, generated with SWIG, named simannealfile.py . It
is beginning like the following:<br>
<br>
<i># This file was created automatically by SWIG.</i><i><br>
</i><i>import simannealfilec</i><i><br>
</i><i>class simanneal_varlist:</i><i><br>
</i><i>&nbsp;&nbsp;&nbsp; def __init__(self,*args):</i><i><br>
</i><i>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.this = apply(simannealfilec.new_simanneal_varlist,args)</i><i><br>
</i><i>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.thisown = 1</i><i><br>
</i><i><br>
</i><i>&nbsp;&nbsp;&nbsp; def __del__(self,simannealfilec=simannealfilec):</i><i><br>
</i><i>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if getattr(self,'thisown',0):</i><i><br>
</i><i>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; simannealfilec.delete_simanneal_varlist(self)</i><br>
...<br>
<br>
I imported this File in another Module named mainko.py :<br>
<br>
<i>import string,re,sys,glob,operator</i><i><br>
</i><i>import simannealfile</i><i><br>
</i><i><br>
</i><i><br>
</i><i>instance1=simannealfile.simulated_annealing()</i><i><br>
</i><i><br>
</i><i>fx=instance1.optimize()</i><i><br>
</i><i><br>
</i><i>print 'test=',fx</i><br>
<br>
The mainko.py file is just a dummy to test teh correct function, but after
executing the following output appers:<br>
<br>
<i>Traceback (most recent call last):</i><i><br>
</i><i>&nbsp; File "c:\programme\python21\pythonwin\pywin\framework\scriptutils.py",
line 396, in ImportFile</i><i><br>
</i><i>&nbsp;&nbsp;&nbsp; reload(sys.modules[modName])</i><i><br>
</i><i>&nbsp; File "C:\Arbeit_Diplomarbeit\__Optimierer\ext1\mainko.py", line
2, in ?</i><i><br>
</i><i>&nbsp;&nbsp;&nbsp; import simannealfile</i><i><br>
</i><i>&nbsp; File "C:\Arbeit_Diplomarbeit\__Optimierer\ext1\simannealfile.py",
line 2, in ?</i><i><br>
</i><i>&nbsp;&nbsp;&nbsp; import simannealfilec</i><i><br>
</i><i>ImportError: No module named simannealfilec<br>
<br>
</i>Python seems to have problems finding the file simannealfilec .This file
is automatically generated by the SWIG Wrapper an no visible. <br>
So, it would be very good, if anyone has got a solution to my problem.<br>
<br>
Greetings<br>
Marcus<br>
<i><br>
<br>
<br>
</i><br>
<br>
</body>
</html>

--------------010708010408010104060307--