mirror of
https://github.com/python/cpython.git
synced 2025-09-26 10:19:53 +00:00
Use type(x).__name__ to get the name of the type instead of parsing
repr(type(x)).
This commit is contained in:
parent
0263c80b90
commit
a995c91243
1 changed files with 1 additions and 1 deletions
|
@ -14,7 +14,7 @@ class Repr:
|
||||||
def repr(self, x):
|
def repr(self, x):
|
||||||
return self.repr1(x, self.maxlevel)
|
return self.repr1(x, self.maxlevel)
|
||||||
def repr1(self, x, level):
|
def repr1(self, x, level):
|
||||||
typename = `type(x)`[7:-2] # "<type '......'>"
|
typename = type(x).__name__
|
||||||
if ' ' in typename:
|
if ' ' in typename:
|
||||||
parts = typename.split()
|
parts = typename.split()
|
||||||
typename = '_'.join(parts)
|
typename = '_'.join(parts)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue