Glauco wrote:
> 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.
>
>   

yes of course [1,2,3] is different than [3,2,1] (hopefully), I was 
talking for InstrumentedList, not tuple or list or ...

Anyway, I've used  sorted(MyInstrumentList...) == 
sorted(MyInstrumentList2 or MyTuple or ...) ... which works :-)

>
>   
>> 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
>
>   


-- 
Julien Cigar
Belgian Biodiversity Platform
http://www.biodiversity.be
Université Libre de Bruxelles (ULB)
Campus de la Plaine CP 257
Bâtiment NO, Bureau 4 N4 115C (Niveau 4)
Boulevard du Triomphe, entrée ULB 2
B-1050 Bruxelles
office: [EMAIL PROTECTED]
home: [EMAIL PROTECTED]
biobel reference: http://biobel.biodiversity.be/biobel/person/show/471


--~--~---------~--~----~------------~-------~--~----~
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