16 lines
295 B
Python
16 lines
295 B
Python
|
|
def isid(obj):
|
|
"""
|
|
Returns true if the given object can be converted to an ID, false otherwise.
|
|
"""
|
|
if hasattr(obj, "id"):
|
|
return True
|
|
else:
|
|
try:
|
|
int(obj)
|
|
except ValueError:
|
|
return False
|
|
else:
|
|
return True
|
|
|