Closed jamadden closed 3 years ago
Pending discussion of this, I'd like to go ahead and publish the trunk to PyPI as zope.interface 5.3.0a1; that will unblock zope.component to move forward (https://github.com/zopefoundation/zope.component/pull/53 and https://github.com/zopefoundation/zope.component/pull/55).
If we decide to go ahead with these changes, I can make the PR, and then we can release that as 5.3.0.
If we decide not to make these changes, I can release 5.3.0 with no changes from 5.3.0a1.
I'll wait at least an hour before taking any action.
I like it.
(Moved from https://github.com/zopefoundation/zope.interface/pull/234#discussion_r596750717)
Given
spec = Provides(AClass, IFoo, IBar)
, the repr will be something likeInformative, but not terse.
Basically none of these objects have a
__str__
method.__repr__
is meant to "look like a valid Python expression that could be used to recreate an object with the same value (given an appropriate environment)."In contrast
__str__
computes "the 'informal' string representation of an object. This differs from__repr__()
in that it does not have to be a valid Python expression: a more convenient or concise representation may be used instead. The return value must be a string object."For
Provides
, it would be pretty easy to give arepr
that actually can be evaluated (in many cases) outputting something likeSimilarly, interfaces could have a
__str__
that just outputs__module__.__name__
.That would transform reports from
to
(With similar benefits when
Provides
is present.)Since the changes in
Provides
in #234 mean that there might have to be doctest updates, and since adding a__str__
mostly shouldn't (but might!) cause doctest updates, this might be a good time (before 5.3) to make such a change.What do you think?