summaryrefslogtreecommitdiffstats
path: root/Lib/os.py
diff options
context:
space:
mode:
authorLeonardo Freua <leonardo.batista.freua@gmail.com>2021-07-20 17:15:45 (GMT)
committerGitHub <noreply@github.com>2021-07-20 17:15:45 (GMT)
commit85fa3b6b7c11897732fedc443db0e4e8e380c8f8 (patch)
tree98985ed2b78e1ec4689b1da1204b729cfe2deab3 /Lib/os.py
parent42205ee512159de62c01e202ff799d78fac9ac26 (diff)
downloadcpython-85fa3b6b7c11897732fedc443db0e4e8e380c8f8.zip
cpython-85fa3b6b7c11897732fedc443db0e4e8e380c8f8.tar.gz
cpython-85fa3b6b7c11897732fedc443db0e4e8e380c8f8.tar.bz2
bpo-44631: Make the repr() of the _Environ class more readable. (#27128)
Co-authored-by: Ɓukasz Langa <lukasz@langa.pl>
Diffstat (limited to 'Lib/os.py')
-rw-r--r--Lib/os.py8
1 files changed, 5 insertions, 3 deletions
diff --git a/Lib/os.py b/Lib/os.py
index d26cfc9..8cc70a1 100644
--- a/Lib/os.py
+++ b/Lib/os.py
@@ -704,9 +704,11 @@ class _Environ(MutableMapping):
return len(self._data)
def __repr__(self):
- return 'environ({{{}}})'.format(', '.join(
- ('{!r}: {!r}'.format(self.decodekey(key), self.decodevalue(value))
- for key, value in self._data.items())))
+ formatted_items = ", ".join(
+ f"{self.decodekey(key)!r}: {self.decodevalue(value)!r}"
+ for key, value in self._data.items()
+ )
+ return f"environ({{{formatted_items}}})"
def copy(self):
return dict(self)