Changes between Version 17 and Version 18 of PythonGotchas
- Timestamp:
- Jul 24, 2019, 1:43:05 PM (5 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
PythonGotchas
v17 v18 51 51 >>> dataset = gdal.Open('C:\\RandomData.img') 52 52 >>> band = dataset.GetRasterBand(1) 53 >>> print band.Checksum()53 >>> print(band.Checksum()) 54 54 31212 55 55 }}} … … 72 72 #!python 73 73 >>> from osgeo import gdal 74 >>> print gdal.Open('C:\\RandomData.img').GetRasterBand(1).Checksum()74 >>> print(gdal.Open('C:\\RandomData.img').GetRasterBand(1).Checksum()) 75 75 < Python crashes > 76 76 }}} … … 101 101 >>> feature.SetGeometryDirectly(point) # Transfers ownership of the C++ geometry from point to feature 102 102 >>> del feature # point becomes implicitly invalid, because feature owns the C++ geometry 103 >>> print point.ExportToWkt()# Crash here103 >>> print(point.ExportToWkt()) # Crash here 104 104 < Python crashes > 105 105 }}} … … 134 134 >>> for i in range( 0, lyr.GetFeatureCount() ): 135 135 ... 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 feat136 ... print(feat) # this will print one feat, but it's the first feat in the Layer and not the filtered feat 137 137 ... 138 138 }}} … … 240 240 gdal.Error(gdal.CE_Warning,1,'Test warning message') 241 241 except Exception as e: 242 print 'Operation raised an exception'243 raise 242 print('Operation raised an exception') 243 raise e 244 244 else: 245 245 if err.err_level >= gdal.CE_Warning: 246 print 'Operation raised an warning'246 print('Operation raised an warning') 247 247 raise RuntimeError(err.err_level, err.err_no, err.err_msg) 248 248 finally: