[Checkins] SVN:
zope.app.undo/branches/nikhil_n-py25/src/zope/app/undo/__init__.py made
zope.app.undo work with Python 2.5
Christian Theune
ct at gocept.com
Sat Jul 7 09:17:50 EDT 2007
Hi,
Am Samstag, den 07.07.2007, 09:08 -0400 schrieb Benji York:
> nikhil n wrote:
> > Log message for revision 77570:
> > made zope.app.undo work with Python 2.5
>
> Correct me if I'm wrong, but it looks like __eq__ below could be changed
> to just
>
> def __eq__(self, other):
> return other and unicode(other).startswith(self)
>
> (Not sure if the call to unicode is even needed, but I don't know what
> this code is really doing.)
Jumping on this train. Even if it's not the same, I'd propose a more
readable spelling of what happens below.
For one:
"unicode(other[:len(self)]).__eq__(self) == 1:" is reeeaaally hard to
understand without looking very closely. Benji's approach is easily
understandable.
Also, the code has quite some redundancy in it, the only difference in
the "except" block is in the use of __eq__ instead of __cmp__. And it's
not immediately clear that a missing __cmp__ will trigger the
AttributeError. There's a lot more going on that *potentially* could
trigger it. Looking closely it's the onlye likely source though.
I'd at least split the code into two parts: determine whether to use
__cmp__ or __eq__ and then apply the test.
If startswith() is what you wanted then it becomes even simpler.
Christian
More information about the Checkins
mailing list