Why not go for f-strings (Python 3.6+). See for instance:
http://zetcode.com/python/fstring/
The code:
def __repr__(self):
# Better for g.printObj.
val = str(self.val).replace('\n', ' ')
return 'GS: %20s %7s = %s' % (
g.shortFileName(self.path), self.kind, g.truncate(val, 50))
would look as follows:
def __repr__(self):
# Better for g.printObj.
val = (str(self.val).replace('\n', ' '))[0:50] # Save call to g.truncate
return f'GS: {g.shortFileName(self.path):20} {self.kind:7} = {val}'
Less typing, Smaller, faster, cleaner.
--
You received this message because you are subscribed to the Google Groups
"leo-editor" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/leo-editor/75137e8f-3f5d-4dab-a2b6-e03862d68047%40googlegroups.com.