Changes between Version 7 and Version 8 of GSoC2008
- Timestamp:
- Jun 30, 2008, 4:21:54 PM (16 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
GSoC2008
v7 v8 22 22 23 23 {{{ 24 <a href="/edit/1" py:if="user.aut orized()">[edit]</a>24 <a href="/edit/1" py:if="user.authorized()">[edit]</a> 25 25 <p>1111 11 11</p> 26 <a href="/edit/2" py:if="user.aut orized()">[edit]</a>26 <a href="/edit/2" py:if="user.authorized()">[edit]</a> 27 27 <p>222 22 22 2</p> 28 <a href="/edit/3" py:if="user.aut orized()">[edit]</a>28 <a href="/edit/3" py:if="user.authorized()">[edit]</a> 29 29 <p>333 33333 33 333</p> 30 30 }}} … … 41 41 }}} 42 42 Now fragment depends only on variable "a", which can be only True or False, which gives optimization possibilities. 43 44 Or it should be even vars = "a = bool(user.authorized())" to avoid things like that: 45 46 {{{ 47 >>> class Foo(object): 48 ... def __len__(self): 49 ... print "Sideeffect" 50 ... return 1 51 ... 52 >>> f = Foo() 53 >>> if f: 54 ... print "Something" 55 ... 56 Sideeffect 57 Something 58 }}} 59 60 Foo can also change its internal state, and return different values in different ifs, which is not good. Only when variable is pure bool (a.__class__ is bool) we are safe. :-)