newbie-question: interfaces

merman merman at freenet.de
Sat Apr 13 10:51:33 EDT 2002


Hi Franz,

very polite of you - thanx for the good described hints/ examples.
I will try ;-).

best regards

Thomas


"F. GEIGER" <fgeiger at datec.at> schrieb im Newsbeitrag
news:a999hl$nmd$1 at rex.ip-plus.net...
> You have to do this by yourself, i.e. there's no built-in support for this
>
>
> class Abstract: # All subclasses of this have to conform to this
>    def __init__(self):
>       return
>
>    def method(self):
>       raise NotImplementedError # Oops, you are working with an Abstract
> object or you have forgotten to override method()!
>
>
> class Concrete:
>    def __init__(self):
>       Abstract.__init__(self)
>       return
>
>    def method(self):
>       pass # Your stuff goes here
>       return
>
>
> a = Abstract()
> a.method() # Will raise an error
>
> c = Concrete()
> c.method() # Will do, what you told it to do
>
>
> Try Google to find more on this as this is frequently discussed here.
>
> Best regards
> Franz
>
> "merman" <merman at freenet.de> schrieb im Newsbeitrag
> news:3cb7f47e$0$360$9b622d9e at news.freenet.de...
> > Hi,
> >
> > is there a way to simulate interfaces (like in java) in python?
> > ... or abstract classes? (c++/ java)
> >
> > o-o
> >
> > thomas
> >
> >
> >
> >
>
>





More information about the Python-list mailing list