How to dervie from an instance object?

R

reinsn

Hi,

I am currently working with ZopeX3. Because python doesn't include
concept of interfaces, those were defined by the module zope.interface.

So interfaces were defined like:

class IMyInterface(zope.interface.Interface):
.....


I have looked into the module zope.interface and found, that
zope.interface.Interface is an object instance and no class object! But
how does this work? How can I derive from an object instance?

I mean is something like this possible in Python?

class X: pass

x = X()

class Y (x):
.....


Thanks for the replies in advance!
 
B

bruno at modulix

reinsn said:
Hi,

I am currently working with ZopeX3. Because python doesn't include
concept of interfaces,

It does, but implicitly. The interface of an object is the set of
messages it understands.
those were defined by the module zope.interface.

So interfaces were defined like:

class IMyInterface(zope.interface.Interface):
.....

I have looked into the module zope.interface and found, that
zope.interface.Interface is an object instance and no class object! But
how does this work? How can I derive from an object instance?

Python classes *are* objects - instances of their metaclass.
I mean is something like this possible in Python?

class X: pass

x = X()

class Y (x):
.....

Not directly. Google for Python +metaclass.
 

Ask a Question

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.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,289
Messages
2,571,435
Members
48,121
Latest member
ColinHibne

Latest Threads

Top