Use dict comprehensions

This commit is contained in:
Daniele Varrazzo 2017-11-28 15:47:35 +00:00
parent c3ee9cac41
commit f939f39580
2 changed files with 3 additions and 6 deletions

View File

@ -181,11 +181,8 @@ class Range(object):
return self.__gt__(other)
def __getstate__(self):
return dict(
(slot, getattr(self, slot))
for slot in self.__slots__
if hasattr(self, slot)
)
return {slot: getattr(self, slot)
for slot in self.__slots__ if hasattr(self, slot)}
def __setstate__(self, state):
for slot, value in state.items():

View File

@ -163,7 +163,7 @@ def make_dsn(dsn=None, **kwargs):
kwargs['dbname'] = kwargs.pop('database')
# Drop the None arguments
kwargs = dict((k, v) for (k, v) in kwargs.iteritems() if v is not None)
kwargs = {k: v for (k, v) in kwargs.iteritems() if v is not None}
if dsn is not None:
tmp = parse_dsn(dsn)