[New-bugs-announce] [issue13166] Implement packaging.database.Distribution.__str__

Éric Araujo report at bugs.python.org
Thu Oct 13 17:52:11 CEST 2011

New submission from Éric Araujo <merwok at netwok.org>:

In code working with instances of packaging.database.Distribution, it’s bothersome to have to use '%r %s' % (dist.name, dist.version) all the time.  It is also not good-looking in 2.x, where we get u'name'.  I think it would be best to implement a __str__ method on the class and just use %s everywhere, for example in pysetup list and pysetup search.  More sophisticated clients that want to display projects in a GUI can still access dist.name, dist.version and other attributes.

I’ve insisted on using %r for project names and paths to avoid ambiguities with trailing spaces and such hard-to-catch things.  For logging output, we have to pass pure strings, but for direct console printing we could use ANSI escape sequences to display projects’ names in bold for example.

assignee: tarek
components: Distutils2
messages: 145463
nosy: alexis, eric.araujo, tarek
priority: normal
severity: normal
status: open
title: Implement packaging.database.Distribution.__str__
versions: 3rd party, Python 3.3

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list