Mercurial > ~astiob > upreckon > hgweb
comparison compat.py @ 68:e00ab6d1f0ba
Corrected the implementation of callable() for Python 3.0 and 3.1
author | Oleg Oshmyan <chortos@inbox.lv> |
---|---|
date | Mon, 27 Dec 2010 23:14:27 +0200 |
parents | e0f8b28e15b5 |
children | b9d5857f7b9a |
comparison
equal
deleted
inserted
replaced
67:e0f8b28e15b5 | 68:e00ab6d1f0ba |
---|---|
161 range = range | 161 range = range |
162 | 162 |
163 try: | 163 try: |
164 callable = callable | 164 callable = callable |
165 except NameError: | 165 except NameError: |
166 callable = lambda obj: hasattr(obj, '__call__') | 166 from collections import Callable |
167 callable = lambda obj: isinstance(obj, Callable) | |
167 | 168 |
168 try: | 169 try: |
169 next = next | 170 next = next |
170 except NameError: | 171 except NameError: |
171 next = lambda obj: obj.next() | 172 next = lambda obj: obj.next() |