mirror of
https://github.com/kennethreitz/tablib.git
synced 2026-06-05 06:56:13 +00:00
Merge multiple isinstance() calls to one
This commit is contained in:
+3
-3
@@ -179,7 +179,7 @@ class Dataset(object):
|
||||
|
||||
|
||||
def __getitem__(self, key):
|
||||
if isinstance(key, str) or isinstance(key, unicode):
|
||||
if isinstance(key, (str, unicode)):
|
||||
if key in self.headers:
|
||||
pos = self.headers.index(key) # get 'key' index from each data
|
||||
return [row[pos] for row in self._data]
|
||||
@@ -198,7 +198,7 @@ class Dataset(object):
|
||||
|
||||
|
||||
def __delitem__(self, key):
|
||||
if isinstance(key, str) or isinstance(key, unicode):
|
||||
if isinstance(key, (str, unicode)):
|
||||
|
||||
if key in self.headers:
|
||||
|
||||
@@ -895,7 +895,7 @@ class Dataset(object):
|
||||
sorted.
|
||||
"""
|
||||
|
||||
if isinstance(col, str) or isinstance(col, unicode):
|
||||
if isinstance(col, (str, unicode)):
|
||||
|
||||
if not self.headers:
|
||||
raise HeadersNeeded
|
||||
|
||||
@@ -14,7 +14,7 @@ extensions = ('json', 'jsn')
|
||||
|
||||
|
||||
def serialize_objects_handler(obj):
|
||||
if isinstance(obj, decimal.Decimal) or isinstance(obj, UUID):
|
||||
if isinstance(obj, (decimal.Decimal, UUID)):
|
||||
return str(obj)
|
||||
elif hasattr(obj, 'isoformat'):
|
||||
return obj.isoformat()
|
||||
|
||||
Reference in New Issue
Block a user