Mercurial > public > mercurial-scm > python-hglib
comparison hglib/util.py @ 149:958307b30af3
hglib: add a __bool__ method where __nonzero__ is defined (issue4520)
Python 3 uses the __bool__ magic method for determining the boolean
value of an object instead of __nonzero__.
author | Brett Cannon <brett@python.org> |
---|---|
date | Mon, 16 Mar 2015 17:59:27 -0400 |
parents | c1b966866ed7 |
children | b94e1263836c |
comparison
equal
deleted
inserted
replaced
148:c1b966866ed7 | 149:958307b30af3 |
---|---|
147 | 147 |
148 def __nonzero__(self): | 148 def __nonzero__(self): |
149 """ Returns True if the return code was 0, False otherwise """ | 149 """ Returns True if the return code was 0, False otherwise """ |
150 return self.ret == 0 | 150 return self.ret == 0 |
151 | 151 |
152 def __bool__(self): | |
153 return self.__nonzero__() | |
154 | |
152 class propertycache(object): | 155 class propertycache(object): |
153 """ | 156 """ |
154 Decorator that remembers the return value of a function call. | 157 Decorator that remembers the return value of a function call. |
155 | 158 |
156 >>> class obj(object): | 159 >>> class obj(object): |