Python Mapscript :: NameError: global name 'rectObj' is not defined

Sean Gillies sgillies at FRII.COM
Mon Aug 23 12:56:28 EDT 2004


On Aug 23, 2004, at 10:42 AM, Bill Hudspeth wrote:

> I am trying to create a rectangle object using Python Mapscript as
> such:
>
> prevExtent = rectObj(self.prev_minx, self.prev_miny, self.prev_maxx,
> self.prev_maxy)
>
> and get the following error message:
>
> NameError: global name 'rectObj' is not defined
>
>
> I have imported the mapscript module - other mapscript objects are
> recognized in different calls throughout my code, so that is not the
> problem.
>
> Any other ideas would be greatly appreciated.
>
> Thanks, Bill
>

Bill,

There's two different styles of using mapscript classes

1. keep mapscript class names inside the 'mapscript' namespace:

     import mapscript
     r = mapscript.rectObj()

2. import names into the global namespace:

     from mapscript import rectObj
     r = rectObj()

I don't recommend 'from mapscript import *'.

cheers,
Sean

--
Sean Gillies
sgillies at frii dot com
http://users.frii.com/sgillies



More information about the mapserver-users mailing list