Changes between Version 17 and Version 18 of PythonGotchas


Ignore:
Timestamp:
Jul 24, 2019, 1:43:05 PM (13 months ago)
Author:
Mike Taves
Comment:

Python 3 fixes

Legend:

Unmodified
Added
Removed
Modified
  • PythonGotchas

    v17 v18  
    5151>>> dataset = gdal.Open('C:\\RandomData.img')
    5252>>> band = dataset.GetRasterBand(1)
    53 >>> print band.Checksum()
     53>>> print(band.Checksum())
    545431212
    5555}}}
     
    7272#!python
    7373>>> from osgeo import gdal
    74 >>> print gdal.Open('C:\\RandomData.img').GetRasterBand(1).Checksum()
     74>>> print(gdal.Open('C:\\RandomData.img').GetRasterBand(1).Checksum())
    7575< Python crashes >
    7676}}}
     
    101101>>> feature.SetGeometryDirectly(point)    # Transfers ownership of the C++ geometry from point to feature
    102102>>> del feature                           # point becomes implicitly invalid, because feature owns the C++ geometry
    103 >>> print point.ExportToWkt()             # Crash here
     103>>> print(point.ExportToWkt())            # Crash here
    104104< Python crashes >
    105105}}}
     
    134134>>> for i in range( 0, lyr.GetFeatureCount() ):
    135135...    feat = lyr.GetFeature( i )
    136 ...    print feat                                     # this will print one feat, but it's the first feat in the Layer and not the filtered feat 
     136...    print(feat)                                    # this will print one feat, but it's the first feat in the Layer and not the filtered feat 
    137137...
    138138}}}
     
    240240        gdal.Error(gdal.CE_Warning,1,'Test warning message')
    241241    except Exception as e:
    242         print 'Operation raised an exception'
    243         raise
     242        print('Operation raised an exception')
     243        raise e
    244244    else:
    245245        if err.err_level >= gdal.CE_Warning:
    246             print 'Operation raised an warning'
     246            print('Operation raised an warning')
    247247            raise RuntimeError(err.err_level, err.err_no, err.err_msg)
    248248    finally: