def can(self, permissions):
return self.role is not None and \
(self.role.permissions & permissions) == permissions
我想问下直接用self.role.permissions==permissions 不可以吗为什么要用
(self.role.permissions & permissions) == permissions 优点在哪里
1
MartinWu 2015-07-19 01:42:42 +08:00
依我愚见,(self.role.permissions & permissions) == permissions 等同于 permissions is not None and self.role.permissions==permissions
|
2
realityone 2015-07-19 09:57:47 +08:00
self.role.permissions = 0xFFFFFFFF
permissions = 0x0000FFFF self.role.permissions != permissions (self.role.permissions & permissions) = permissions |