Python: Difference between revisions

From Wildsong
Jump to navigationJump to search
Brian Wilson (talk | contribs)
Brian Wilson (talk | contribs)
 
(41 intermediate revisions by the same user not shown)
Line 1: Line 1:
Brian's random notes on Python
== About this page ==


== Python on Pocket PC
Wow, it's been a long time since I touched this page! I actually know how to program in Python now, so I don't need to update it.


== Links ==
Okay... I don't know Python + Opensource GIS, so I found this link:
http://www.gis.usu.edu/~chrisg/python/2009/


[http://pythonce.sourceforge.net/ Python on Windows CE] (and Pocket PC)
I do a lot of Python for ESRI Geoprocessing.
I also tend to use Python on the Mac, so I use GDAL and QGIS there.
 
== Python on Windows ==
 
I am starting a separate page on [[Portable Windows]] tools.
 
=== PIP ===
 
My pattern is to use the standard ESRI Python things but there is also
[https://sites.google.com/site/pydatalog/python/pip-for-windows PIP for Windows] when you need to install additional packages.
 
== IDE ==
 
=== Spyder ===
 
Pretty much all I used now, because it's free and because it runs on Windows without requiring installation (no admin rights required).
There are also Linux and Mac versions. The debugger works but needs more development. Auto-complete is part way there.
See [[Anaconda]].
 
=== Komodo ===
 
I used to use ActiveState Komodo. I think it's about $300. That is for a 'personal' license which means I have permission to install it on all my computers. I admire this approach - I only use one computer at a time so it's not like it hurts Activestate. For free, they have an editor "Open Komodo" but I need the debugger.
 
If you try the eval version you won't want to go back to PythonWin.
 
=== Wing ===
 
Wing is another commercial Python IDE. I tried it, it is probably really good. I think it has Iron Python support which is something I hope to see in Komodo.
 
I have a coworker who uses it and we compare notes from time to time. It's equivalent to Komodo. Take your pick.
 
=== Eclipse ===
 
Eclipse is my last choice for Python.
 
=== SPE ===
 
http://pythonide.stani.be/ Python IDE
 
== GUI ==
 
So far I have used Python for scripting operations such as geoprocessing.
Now I am at the stage where I want to start designing GUI based applications especially ones that can be portable between Windows and Linux.
 
Currently I am trying out [[PyQT]].
 
I also tried wxWindows and wxPython. I found the designer to be less useful than QT4 Designer.
 
wxWindows http://wxwindows.org/ a portable GUI platform for forms based on GTK
 
wxWidgets http://wxwidgets.org/ the widgets used by wxWindows.
 
== Web development ==
 
I am writing a web application in Python right now so I have another page started.
[[Python for Web Applications]]
 
==== Some relevant Ubuntu packages ====
 
For PyQT, there is a set of QT packages.
 
For wxPython, '''boa-constructor''' RAD tool http://boa-constructor.sourceforge.net/ (Application runs under Linux and Windows)
Last release was in 2007, not a good sign. Maybe it's perfect?
There is a commercial product that is probably the spirtual heir to boa-constructor called wxDesigner. See http://www.wxdesigner-software.de/
 
'''python-card''' GUI construction framework http://pythoncard.sourceforge.net/
"PythonCard is a GUI construction kit for building cross-platform desktop applications on Windows, Mac OS X, and Linux, using the Python language."
I still have fond memories of HyperCard so this one is interesting to me.
 
'''python-wxglade''' GUI designer
 
'''python-wxtools'''
 
'''python-wxversion'''
 
''Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius — and a lot of courage — to move in the opposite direction.'' -- Albert Einstein
 
== Databases ==
 
From the ArcGIS perspective, I can access geodatabases using ArcObjects
but for the frequent occasions when it runs out of gas, I can tap into the
underlying databases.
 
For shapefiles I can use [[#Links|dbfpy]] to read and write the
attributes, which are stored in the .dbf file.
 
For personal geodatabases I can tap into the MDB using
either ODBC or OLEDB. See [[Accessing Personal Geodatabases with Python]]
 
For file geodatabases... well, ESRI has not released specs yet so I use PGDB's.
 
== Geoprocessing ==
 
Content from this section has moved to the [[Geoprocessing]] page.
 
== Network programming ==
 
I am trying to tear apart packets with Python to write some network code.
I am using a module called [[Scapy]] and I have started a separate page to keep notes on it.
 
== XML ==


=== Quick links into the official docs ===
I am trying to parse a GPX document, so that I can write an ESRI feature class as output. I want to be able to give the script away, so I need to work with the version of Python that is installed with ESRI ArcGIS. When working with ArcGIS, the choices for XML are


TUTORIAL  http://docs.python.org/tut/tut.html
* xml.dom
* xml.etree http://docs.python.org/library/xml.etree.elementtree.html
* xml.parsers.expat http://docs.python.org/library/pyexpat.html
* xml.sax


GENERAL    http://docs.python.org/
Actually I just got source from http://arcscripts.esri.com/
that I only need to update a bit. It's using the xml.etree flavour.
Look here: http://arcscripts.esri.com/details.asp?dbid=16797


STRINGS    http://docs.python.org/lib/string-methods.html
== External Links ==


http://diveintopython.org/
[http://sourceforge.net/projects/dbfpy dbfpy] for accessing .dbf files


=== Geoprocessing ===
[http://pythonce.sourceforge.net/ Python on Windows CE] (and Pocket PC)


==== ESRI ====


This guy seems to have slogged through a lot of development with it and collected useful notes: http://www.ollivier.co.nz/support/python.shtm


I can add a new one to his list. I was getting error messages on setting gp.workspace = 'foo' where ''foo'' is a valid path. It's because the gp object was hanging around in pythonwin's memory. You should be able to say 'del gp' but I gave up and restarted pythonwin to fix it.
http://pyswarm.sourceforge.net/


When working with ArcToolbox 9.1 and Python 2.1 I have been having lots of crashes in PythonWin. Using it on a computer with ActiveState 2.4.3 I have not been experiencing the same problems. I am going to try installing 2.4x without removing 2.1 so I can fall back on it... I followed the instructions above.
http://plone.org/about/movies


It still crashes. Oh joy. It does not even crash faster.
=== Links into official python docs ===


==== Open source ====
TUTORIAL  http://docs.python.org/tut/tut.html


How about geoprocessing with [http://www.gdal.org OGR/GDAL]?
GENERAL    http://docs.python.org/
Will that do it for me?


Getting Python 2.4 and GDAL without disrupting the ESRI installation... See also [http://hobu.biz/ Howard Butler's site].
STRINGS    http://docs.python.org/lib/string-methods.html


'''Not good enough:''' [http://fwtools.maptools.org/ FWtools] installs a funky GUI called OpenEV_FW and a shell environment.
http://diveintopython.org/
It comes with python 2.3.4 which is old but better than ESRI's 2.1
'''It does NOT include the pythonwin IDE'''. How INCORNVENIENT!


'''23-Aug-2006''' Python+OGR probably not worth messing with right now.
[[Category: Python]]
From the OGR site: ''The Python API isn't really well documented at this time, but parallels the C/C++ APIs. The interface classes can be browsed in the pymod/ogr.py (simple features) and pymod/osr.py (coordinate systems) python modules. The pymod/samples/assemblepoly.py sample script is one demonstration of using the python API.''
[[Category: GIS]]

Latest revision as of 16:57, 19 December 2017

About this page

Wow, it's been a long time since I touched this page! I actually know how to program in Python now, so I don't need to update it.

Okay... I don't know Python + Opensource GIS, so I found this link: http://www.gis.usu.edu/~chrisg/python/2009/

I do a lot of Python for ESRI Geoprocessing. I also tend to use Python on the Mac, so I use GDAL and QGIS there.

Python on Windows

I am starting a separate page on Portable Windows tools.

PIP

My pattern is to use the standard ESRI Python things but there is also PIP for Windows when you need to install additional packages.

IDE

Spyder

Pretty much all I used now, because it's free and because it runs on Windows without requiring installation (no admin rights required). There are also Linux and Mac versions. The debugger works but needs more development. Auto-complete is part way there. See Anaconda.

Komodo

I used to use ActiveState Komodo. I think it's about $300. That is for a 'personal' license which means I have permission to install it on all my computers. I admire this approach - I only use one computer at a time so it's not like it hurts Activestate. For free, they have an editor "Open Komodo" but I need the debugger.

If you try the eval version you won't want to go back to PythonWin.

Wing

Wing is another commercial Python IDE. I tried it, it is probably really good. I think it has Iron Python support which is something I hope to see in Komodo.

I have a coworker who uses it and we compare notes from time to time. It's equivalent to Komodo. Take your pick.

Eclipse

Eclipse is my last choice for Python.

SPE

http://pythonide.stani.be/ Python IDE

GUI

So far I have used Python for scripting operations such as geoprocessing. Now I am at the stage where I want to start designing GUI based applications especially ones that can be portable between Windows and Linux.

Currently I am trying out PyQT.

I also tried wxWindows and wxPython. I found the designer to be less useful than QT4 Designer.

wxWindows http://wxwindows.org/ a portable GUI platform for forms based on GTK

wxWidgets http://wxwidgets.org/ the widgets used by wxWindows.

Web development

I am writing a web application in Python right now so I have another page started. Python for Web Applications

Some relevant Ubuntu packages

For PyQT, there is a set of QT packages.

For wxPython, boa-constructor RAD tool http://boa-constructor.sourceforge.net/ (Application runs under Linux and Windows) Last release was in 2007, not a good sign. Maybe it's perfect? There is a commercial product that is probably the spirtual heir to boa-constructor called wxDesigner. See http://www.wxdesigner-software.de/

python-card GUI construction framework http://pythoncard.sourceforge.net/ "PythonCard is a GUI construction kit for building cross-platform desktop applications on Windows, Mac OS X, and Linux, using the Python language." I still have fond memories of HyperCard so this one is interesting to me.

python-wxglade GUI designer

python-wxtools

python-wxversion

Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius — and a lot of courage — to move in the opposite direction. -- Albert Einstein

Databases

From the ArcGIS perspective, I can access geodatabases using ArcObjects but for the frequent occasions when it runs out of gas, I can tap into the underlying databases.

For shapefiles I can use dbfpy to read and write the attributes, which are stored in the .dbf file.

For personal geodatabases I can tap into the MDB using either ODBC or OLEDB. See Accessing Personal Geodatabases with Python

For file geodatabases... well, ESRI has not released specs yet so I use PGDB's.

Geoprocessing

Content from this section has moved to the Geoprocessing page.

Network programming

I am trying to tear apart packets with Python to write some network code. I am using a module called Scapy and I have started a separate page to keep notes on it.

XML

I am trying to parse a GPX document, so that I can write an ESRI feature class as output. I want to be able to give the script away, so I need to work with the version of Python that is installed with ESRI ArcGIS. When working with ArcGIS, the choices for XML are

Actually I just got source from http://arcscripts.esri.com/ that I only need to update a bit. It's using the xml.etree flavour. Look here: http://arcscripts.esri.com/details.asp?dbid=16797

External Links

dbfpy for accessing .dbf files

Python on Windows CE (and Pocket PC)


http://pyswarm.sourceforge.net/

http://plone.org/about/movies

Links into official python docs

TUTORIAL http://docs.python.org/tut/tut.html

GENERAL http://docs.python.org/

STRINGS http://docs.python.org/lib/string-methods.html

http://diveintopython.org/