문제

As I was reading peewee docs, I found a surprising statement:

# python code
messages = Message.select().where(
    Message.user << user.following()
)

Wow, can someone please explain what does that do? I know that << is just a lshift (left shift) operator (which moves the binary representation left for intergers, similar behavior applies to right shift), but I didn't know this can handle lists (user.following() is a list). Is it just operator overloading written by peewee authors or some kind of a python core feature I don't know?

도움이 되었습니까?

해결책

pewee indeed uses operator overloading, in this case with the __lshift__ magic method.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top