Resending (got rejected the first time...??)
I came across this in a debugging session this morning... It was very
confusing:
>>> atypes = session.query(AttributeType).select()
>>> atypes
[<AttributeType id=1>, <AttributeType id=2>, <AttributeType id=3>,
<AttributeType id=4>, <AttributeType id=5>, <AttributeType id=6>]
>>> type(atypes)
<type 'instance'>
>>> atypes.__class__
<class sqlalchemy.util.HistoryArraySet at 0x78c2a0>
Issues:
1. the repr of atypes looks like a plain python list, which is
misleading.
2. type(atypes) didn't give me any information about what the type
actually was. This is because HistoryArraySet extends UserList, which
(I believe) is an old-style class.
Proposal 1:
Could we make the __repr__ method of HistoryArraySet follow the model
of the built-in set type? I.E. it would display something like this:
HistoryArraySet([...])
Here's a simple implementation (would need to be changed to use
list.__repr__ if #2 is adopted):
def __repr__(self):
parts = [self.__class__.__name__, "(", ")"]
parts.insert(2, UserList.UserList.__repr__(self))
return "".join(parts)
Proposal 2:
Could HistoryArraySet extend python's built-in list type rather than
UserList? I think this would take care of the type/__class__ issue.
Thanks,
~ Daniel
_______________________________________________
Sqlalchemy-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users