Christopher Barker wrote:
> Sean Gillies wrote:
>> Early on it seemed "nice" to let GIS users check for topological
>> equality using the == operator.
> 
> yes, that is "nice"
> 
>> But it turns out that it's actually
>> harmful. More often, as Eric Lemoine showed me with the SQLAlchemy ORM,
>> we want to reserve that for testing the equality (within the
>> interpreter, non-topological) of Python objects.
> 
> What does equality of python objects mean?
> 
> William Waites wrote:
>> As I understand it, a == b means that a is the same object as b
>> (i.e. lives at the same address in memory)
> 
> Nope. If you want the same object, you use:
> 
> a is b
> 
> a == b means they have the same value:
> 
>  >>> a = (1,2,3)
>  >>> b = (1,2,3)
>  >>> a == b
> True
>  >>> a is b
> False
> 
> -Chris

Of course you are right. I was writing (unclearly) about value, not
identity, equality.

And the reason all this is important is that to GEOS, 2 differently
valued geometries can be topologically equal:

  >>> from shapely.geometry import LineString
  >>> a = LineString(((-1, -1), (1, 1)))
  >>> b = LineString(((-1, -1), (0, 0), (1, 1)))
  >>> a.wkt == b.wkt
  False
  >>> a.equals(b)
  True

Sean
_______________________________________________
Community mailing list
[email protected]
http://lists.gispython.org/mailman/listinfo/community

Reply via email to