[Gdal-dev] ogr.py enhancement proposal

Frank Warmerdam fwarmerdam at gmail.com
Thu Feb 3 09:22:27 EST 2005


On Thu, 3 Feb 2005 09:37:43 +0000, Homme Zwaagstra
<hrz at geodata.soton.ac.uk> wrote:
> In the same vein, would anyone else find an implementation of the
> __str__() method on some objects useful? The Feature and Geometry
> objects spring to mind...
> 
> class Geometry:
>           def __str__(self):
>                   return self.ExportToWkt()
> 
> class Feature:
>           def __str__(self):
>                   return self.DumpReadable()
> 
> This way using the print statement on such an object would be slightly
> more revealing than at present.

Homme, 

I agree some nice __str__ methods on various objects is
desirable.  I have committed the suggested one for the Geometry,
but the call to dumpreadable for the Feature isn't directly viable. 
The __str__ is supposed to return the string representation, but
the DumpReadable() writes it to stdout and returns nothing. 

It would be nice to prepare something similar to what DumpReadable
does (implemented in Python would be fine).  It would also be
nice to have __str__ methods that do something nicer for the various
other objects. 

Best regards,
-- 
---------------------------------------+--------------------------------------
I set the clouds in motion - turn up   | Frank Warmerdam, warmerdam at pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush    | Geospatial Programmer for Rent



More information about the Gdal-dev mailing list