mirror of
https://github.com/python/cpython.git
synced 2025-12-04 00:30:19 +00:00
String method conversion.
This commit is contained in:
parent
141971f22a
commit
6b71e747b1
5 changed files with 14 additions and 18 deletions
|
|
@ -1,7 +1,5 @@
|
|||
"""Redo the `...` (representation) but with limits on most sizes."""
|
||||
|
||||
import string
|
||||
|
||||
class Repr:
|
||||
def __init__(self):
|
||||
self.maxlevel = 6
|
||||
|
|
@ -16,8 +14,8 @@ class Repr:
|
|||
def repr1(self, x, level):
|
||||
typename = `type(x)`[7:-2] # "<type '......'>"
|
||||
if ' ' in typename:
|
||||
parts = string.split(typename)
|
||||
typename = string.joinfields(parts, '_')
|
||||
parts = typename.split()
|
||||
typename = '_'.join(parts)
|
||||
if hasattr(self, 'repr_' + typename):
|
||||
return getattr(self, 'repr_' + typename)(x, level)
|
||||
else:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue