D
Doug Holton
Fredrik said:well, since I'm not in the ego-stroking business, what if I promise never to
reply to posts by you, robert, and alex?
That's not fair to the rest of us though
Fredrik said:well, since I'm not in the ego-stroking business, what if I promise never to
reply to posts by you, robert, and alex?
few days ago when I said that I personally found list comprehensions
more readable than map. I certainly don't mind being advised or
corrected if I've written incorrect or even just suboptimal code, but
attacking a person's mental processes seems kind of needlessly
aggressive to me.
Simon said:We've just had a Python 2.4 release, and poor Mr Lundh has likely had
hundreds of user's clamouring for a binary, 2.4 compatible PIL
release.
Steven said:I don't really have a good solution; despite the unnecessarily vicious
comments, I don't feel like I can set my newsreader to ignore messages
from, for example, Fredrik, because his answers, when not attacks, are
often very insightful. If you find a good solution to this problem,
please let me know.
Doug said:That's not fair to the rest of us though
Steven said:That's not even fair to the non-rest of us. =) As I noted, "his answers
... are often very insightful" -- it would be a pity to lose them.
Doug said:He was only acknowledging the problem to those 3 people who complained
about it. I was making the point that others do not like being trolled
either.
better...)Fredrik said:(I think you could create some kind of drinking game based on the number of
non-quoted lines between the "From"-line and the first line containing the word
"boo" in Doug's posts on comp.lang.python. A little like the game based on the
number of minutes between someone mentioning ElementTree or Anobind or
some other Python/XML toolkit in a blog post, and David Mertz adding a
comment about how his own tool can do the same thing faster and
Doug said:I think there are some solutions like PyProtocols, see section 2.2 on
this page: http://www.python.org/cgi-bin/moinmoin/MetaClasses
Doug said:Thankyou for bringing it up. It looks like it may have a positive effect.
Unfortunately, I may have jumped the gun on that one. He does not even
acknowledge his behavior outside of the three instances he referred to.
Steve said:Even if you can do it, how would you then implement a class hierarchy
where the ultimate base class had virtual methods, and you wanted to
derive from that class another class, to be used as a base class for
usable classes, which implemented only a subset of the virtual methods,
leaving the others to be implemented by the ultimate subclasses?
Mike said:+0
Python doesn't use classes for typing. As Alex Martelli puts it,
Python uses protocols. So the client expecting a concrete subclass of
your abstract class may get an instantiation of a class that doesn't
inherit from the abstract class at all.
I disagree - my reasoning is that a subclass must implement the completeOr maybe the subclass is only going to use a subset of the features of
the abstract class, and the author knows that sum deferred methods
won't be invoked. The correct behavior in this case would be to allow
the subclass to be instantiated, and then get a runtime error if one
of the features the author thought he could skip was actually called.
Finally, in a sufficiently complex class hierarchy, this still leaves
you wondering through the hierarchy trying to find the appropriate
parent class that tagged this method as unimplemented, and then
figuring out which class should have implemented it - as possibly a
parent of the class whose instantiation failed is the subclass that
should have made this method concrete.
<mike
Noam said:But what about the unit tests? They would have still reported a
success - where of course they shouldn't have; my classes, in this
stage, didn't do what they were expected to do. This problem might
arise even when not changing the interface at all - it's quite easy to
write a class which, by mistake, doesn't implement all the interface.
Its successful unit tests may check every single line of code of that
class, but a complete method was simply forgotten, and you wouldn't
notice it until you try the class in the larger framework (and, as I
understand, the point of unit testing is to test the class on its own,
before integrating it).
Jeff said:Except that unit tests should be written to the *specification*, not the
implementation. In other words, forgetting a complete method would
require that you forget to write the method, *and* that you failed to
translate the specification into unit tests *for that same method*.
The problem is that I couldn't write a general unit test, since the baseIn the context of changing an existing interface, a unit-testing
scenario would mean that, instead of installing a "pure virtual" method
on a base class, you'd change the unit-tests to follow the new
specification, and then write code that would pass the unit tests. If
you are subclassing from a common base, then you'd only need to change
the unit test for that common base class (presuming that all derived
classes would run those unit tests as well).
Jeff Shannon
Technician/Programmer
Credit International
Scott said:class Abstract(object):
'''A class to stick anywhere in an inheritance chain'''
__metaclass__ = MustImplement
def notimplemented(method):
'''A decorator for those who prefer the parameters declared.'''
return NotImplemented
Noam Raphael said:The answer is that a subclass is guaranteed to have the same
*interface* as the base class. And that's what matters.
Noam said:Oh, and another thing - maybe "abstract" is a better name than "notimplemented"? notimplemented
might suggest a method which doesn't have to be implemented - and raises NotImplementedError when
it is called. What do you think?
Fredrik said:Noam Raphael wrote:
what's the difference? no, really?
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.