PythonWin -vs- Idle

Niklas Norrthon niklas.norrthon at hotmail.com
Fri Feb 27 01:23:10 EST 2009


On 27 Feb, 01:40, Steve Holden <st... at holdenweb.com> wrote:
> Chris Rebert wrote:
> > On Thu, Feb 26, 2009 at 2:23 PM, Gary Schells <gsche... at hotmail.com> wrote:
> >> Hello,
> >> Python newbie here.  I am working with Python and geoprocessing in ArcGIS.
> >> I'm taking a training course online and the exercise I'm working on makes
> >> mention of using PythonWin instead of Idle.
>
> >> I am using version 2.5 and have not been able to locate PythonWin.  The
> >> download just includes Idle for the environment.  Can anyone point me in the
> >> right direction to download the PythonWin piece of this puzzle?
>
> > Seems to be included inhttp://sourceforge.net/projects/pywin32/
>
> And it's well worth getting, since it's the recommended programming
> environment for ArcGIS. IIRC it uses the COM server capabilities to
> achieve some of the required magic.

It's the recommended programming environment in ESRI's geoprocessing
classes.
The only stuff that is specific to PythonWin is the debugging, (which
you can
do in IDLE too, just in a slightly different way).

Personally I do most of my python hacking in emacs, both when my code
calls
arcgisscripting and otherwise. Sometimes I use IDLE, since in emacs
(and PythonWin)
I miss the ability to restart the interpreter process to get a clean
environment.

There is one thing I use the pywin32 library for, and that is a little
hack to
get around the issue that each version of ArcGIS is bound to a
specific python version:

try:
    import arcgisscripting
except ImportError:
    import win32com.client
    class arcgisscripting(object):
        @staticmethod
        def create():
            return win32com.client.Dispatch
('esriGeoprocessing.GpDispatch.1')

With this little code snippet in a utility module, I can use python
2.6 with ArcGIS, and I can test my scritps with python 2.4, to ensure
that they run in ArcGIS 9.2 environments.

/Niklas Norrthon



More information about the Python-list mailing list