Julien Cigar ha scritto:
> Hi list,
>
> With the following :
>
>  >>> a = Invasive.get(67).habitats
>  >>> b = Invasive.get(57).habitats
>  >>> type(a), type(b)
> (<class 'sqlalchemy.orm.attributes.InstrumentedList'>, <class 
> 'sqlalchemy.orm.attributes.InstrumentedList'>)
>  >>> a == b
> True
>  >>> a
> [<tgias.models.habitat.Habitat object at 0x8d635ec>, 
> <tgias.models.habitat.Habitat object at 0x8d5d8ec>]
>  >>> b
> [<tgias.models.habitat.Habitat object at 0x8d635ec>, 
> <tgias.models.habitat.Habitat object at 0x8d5d8ec>]
>  >>> a.reverse()
>  >>> a
> [<tgias.models.habitat.Habitat object at 0x8d5d8ec>, 
> <tgias.models.habitat.Habitat object at 0x8d635ec>]
>  >>> b
> [<tgias.models.habitat.Habitat object at 0x8d635ec>, 
> <tgias.models.habitat.Habitat object at 0x8d5d8ec>]
>  >>> a == b
> False
>
> Would it not be logical to have True instead of False for the last 
> statement ? 

I don't think so, because the default order is an information !


a == b is a comparo of content so [1,2,3] is different than [3,2,1]
sometimes ordering in presentation of data is a useful information.



> Do you think the order of an InstrumentedList is important 
> for collections (in a boolean context) ?
>   


Yes it is.



You can use set for compare w/out order or a is b for compare identical 
items too.


Glauco

-- 
+------------------------------------------------------------+
                                  Glauco Uri - Programmatore
                                    glauco(at)allevatori.com 
                               
  Sfera Carta Software®      [EMAIL PROTECTED]
  Via Bazzanese,69  Casalecchio di Reno(BO) - Tel. 051591054 
+------------------------------------------------------------+



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to