Вопрос

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