added an own implementation for hasattr (python 2, python 3 is fine)

This commit is contained in:
David Halter
2012-07-13 01:27:41 +02:00
parent 47da6f297f
commit 24577bc632
2 changed files with 12 additions and 1 deletions

View File

@@ -77,3 +77,14 @@ try:
from cStringIO import StringIO as BytesIO
except ImportError:
from io import BytesIO
# hasattr function used because python
if sys.hexversion >= 0x03000000:
hasattr = hasattr
else:
def hasattr(obj, name):
try:
getattr(obj, name)
return True
except AttributeError:
return False

View File

@@ -20,7 +20,7 @@ TODO descriptors (also for classes, for instances it should work)
TODO @staticmethod @classmethod (implement descriptors, builtins are done)
TODO variable assignments in classes (see test/completion/classes @230) +1
"""
from _compatibility import next, property
from _compatibility import next, property, hasattr
import sys
import itertools