开发者

What is an InstrumentedList in Python?

During some set operations I encountered this error in Python:

TypeError: unhashable type: 'InstrumentedList'

What is an InstrumentedList in Python? I only found a few references related to SQLAlchemy. Is this a SQLAlchemy implementation of lists or something?

By the way, it happens while doing:

set(self.som开发者_如何学Ce_list)

where

print type(self.some_list) # <type 'list'>


Yes, SQLAlchemy uses it to implement a list-like object which is aware of insertions and deletions of related objects to an object (via one-to-many and many-to-many relationships).


Yes it's part of SQLAlchemy API. Here is the class reference:

https://docs.sqlalchemy.org/en/20/orm/collection_api.html#sqlalchemy.orm.collections.InstrumentedList

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜