[SciPy-user] Begginer's Problem

Keith Suda-Cederquist kdsudac@yahoo....
Fri Oct 26 14:03:34 CDT 2007


Hi,

I started using SciPy recently (converted from Matlab) and am running into a problem.

I wrote my first script that uses PIL.Image module and several basic SciPy modules.  Within this script I declared functions that used functions in the PIL.Image and scipy modules, for example:


#version1.py
import scipy as S
import PIL.Image as I

def imageopen(filename):
    im1=I.open(filename)
    ar1=S.ones((20,20))
    ....

im2=imageopen(file2)

This worked out fine.  Then I decided it would be nice to move all the function definitions into a seperate file:

#split1.py
def imageopen(filename):
     im1=I.open(filename)
     ar1=S.ones((20,20))

#split2.py
import scipy as S
import PIL.Image as I
import split1

im2=imageopen(file2)

This new structure is giving me a lot of problems.  The usual error I get is that global name 'I' or 'S' is not defined.  I've searched quite a bit for a solution, but haven't figured it out yet.  

As far as I can tell the problem is related to the namespace belonging to particular modules.

I've been able to work around this by importing the scipy and PIL.Image modules all over the place (i.e. at the begging of split1.py and split2.py and inside the function).  However, this doesn't seem like the best way to handle this.

Any advice?

Thanks in advance for your help.

-Keith

 __________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://projects.scipy.org/pipermail/scipy-user/attachments/20071026/1f2d824a/attachment.html 


More information about the SciPy-user mailing list