Usually an abstract class cannot be instantiated:
>>> from abc import ABCMeta, abstractmethod
>>> from fractions import Fraction
>>> class A(Fraction, metaclass=ABCMeta):
@abstractmethod
def frobnicate(self): pass
>>> A()
Traceback (most recent call last):
File "", lin
subclasses what is the correct way in
Python to implement them?
That very much depends on the classes, and how much the abstract classes
do. With the very simple examples you give which have no methods even,
I'd be strongly tempted not to implement the classes at all. But let's
assume that
I am implementing a set of specifications that were designed to be OO
language neutral.
Several classes are specified as being abstract; so therefore there
should be no instances of them, correct?
However in the classes that are subclasses what is the correct way in
Python to implement them?
I am
ople who use that sort of thing. Whatever.
The IAQ's entry on Abstract classes predates the introduction of
Abstract Base Classes to Python 2.6/3.0. Rather than being a "jerk",
the example shows how to produce similar behaviour without code AS
WELL as demonstrating a more extended app
Adam Gaskins wrote:
Wow, thanks Nick! This is just what I was looking for!
I agree that Nick's semi-abstract class is what you need.
After doing some subclasses, you may discover that there is more common
code that you can factor out and push to the base class. You may also
find it convenien
Wow, thanks Nick! This is just what I was looking for!
Thanks to Peter as well. And as for your suggestion that I probably
shouldn't mess with things I don't understand and learn the basics first...
well, that is probably sound advice, but I figured out years ago that I
learn things best by a)
Adam Gaskins wrote:
> So I was beginning to learn OOP for PHP, and it seemed to me that abstract
> classes were just right for my application. In my application I must
> communicate with several peices of test equipment that communicate via
> RS-232. Most use SCPI instructions, som
t; things in such a hackish manner and want to write applications that are
> cross platform (I'd like to get our production dept on linux eventually) and
> truely object oriented.
>
> So I was beginning to learn OOP for PHP, and it seemed to me that abstract
> classes w
Any idea why I didn't see this reply on my ng? I only see the reply from
Marco. Can't help but wonder if there is more that is not getting through
here.
Would someone mind forwarding me any other replies?
FWIW I'm using news.east.cox.net.
Thanks,
-Adam
> Mike Driscoll wrote:
>
>> I've never u
Mike Driscoll wrote:
I've never used (or heard of) the Abstract type...and the guy who
wrote the FAQ was being a jerk.
Who, Peter Norvig?
(from wikipedia)
Peter Norvig is an American computer scientist. He is currently the
Director of Research (formerly Director of Search Quality) at Google
at I seriously dislike: you sound as if OOP
was a goal by itself for you. The point is that OOP is a tool, not a goal.
So, if it helps you do the things you really want, go ahead and use it.
Otherwise, just don't.
> The way I understand abstract classes is that I could have a class that
>
gt; So I was beginning to learn OOP for PHP, and it seemed to me that abstract
> classes were just right for my application. In my application I must
> communicate with several peices of test equipment that communicate via
> RS-232. Most use SCPI instructions, some do not and require low level
12 matches
Mail list logo