I posted a question to this list about the ExtensionClass module that seems to be maintained by the zope developers now. I haven't received a response yet, so I was wondering if this was the right place to ask, or was it because I posted on the weekend and the message got ignored? Rather than reposing it, I will just put a link to it in the archives: http://lists.zope.org/pipermail/zope-dev/2000-February/003389.html It is on subclassing ExtensionClasses in C. James. -- Email: james@daa.com.au WWW: http://www.daa.com.au/~james/
James, I read your message but at the time it wasn't quite clear to me what was needed. I'm no ExtensionClass expert, but I might be able to help. Since your developing a large C extension module and I'm not, I'm going on the assumption that you know more about this than I do, but I was under the impression that classes cannot be defined in C, only types. Therefore, I'm not sure exactly how one would 'subclass' in C, or how one generalizes one C type with another. It is possible of course to create a type that is an extension class, as detailed in the extension class docs and examples. Perhaps you could explain what you need better? Your second question about inheriting methods is beyond me. Or perhaps I don't get the question. -Michel James Henstridge wrote:
I posted a question to this list about the ExtensionClass module that seems to be maintained by the zope developers now.
I haven't received a response yet, so I was wondering if this was the right place to ask, or was it because I posted on the weekend and the message got ignored?
Rather than reposing it, I will just put a link to it in the archives: http://lists.zope.org/pipermail/zope-dev/2000-February/003389.html
It is on subclassing ExtensionClasses in C.
James.
-- Email: james@daa.com.au WWW: http://www.daa.com.au/~james/
_______________________________________________ Zope-Dev maillist - Zope-Dev@zope.org http://lists.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope )
On Thu, 24 Feb 2000, Michel Pelletier wrote:
James,
I read your message but at the time it wasn't quite clear to me what was needed. I'm no ExtensionClass expert, but I might be able to help.
Since your developing a large C extension module and I'm not, I'm going on the assumption that you know more about this than I do, but I was under the impression that classes cannot be defined in C, only types. Therefore, I'm not sure exactly how one would 'subclass' in C, or how one generalizes one C type with another. It is possible of course to create a type that is an extension class, as detailed in the extension class docs and examples. Perhaps you could explain what you need better?
That is the whole point of ExtensionClass -- to create python types in C that look like classes so they can be subclassed. This is a very useful feature, and I wanted to see if I could use ExtensionClass to add this functionality to one of my projects.
Your second question about inheriting methods is beyond me. Or perhaps I don't get the question.
-Michel
Thanks for your time. I guess I should ask Jim Fulton about this problem directly. James.
On Fri, 25 Feb 2000, James Henstridge wrote:
That is the whole point of ExtensionClass -- to create python types in C that look like classes so they can be subclassed. This is a very useful feature, and I wanted to see if I could use ExtensionClass to add this functionality to one of my projects.
Indeed, and if Jim Fulton has/had his way it would have been a standard feature of Python. I have not used it myself, but I certainly remember postings where people mentioned they used it for their own projects. I believe it was on the python main list. Pavlos
James Henstridge wrote:
On Thu, 24 Feb 2000, Michel Pelletier wrote:
James,
I read your message but at the time it wasn't quite clear to me what was needed. I'm no ExtensionClass expert, but I might be able to help.
Since your developing a large C extension module and I'm not, I'm going on the assumption that you know more about this than I do, but I was under the impression that classes cannot be defined in C, only types. Therefore, I'm not sure exactly how one would 'subclass' in C, or how one generalizes one C type with another. It is possible of course to create a type that is an extension class, as detailed in the extension class docs and examples. Perhaps you could explain what you need better?
That is the whole point of ExtensionClass -- to create python types in C that look like classes so they can be subclassed. This is a very useful feature, and I wanted to see if I could use ExtensionClass to add this functionality to one of my projects.
Ah, I think I see where you're coming from, the point of ExtensionClass is to make C types look like classes in Python, but in C they are still types, and there is no mechanism to generalize one type with another, at least not to my knowledge. Quote the ExtensionClass docs:
**Note:** I use *non-standard* terminology here. By standard *python* terminology, only standard python classes can be called classes. ExtensionClass "classes" are technically just "types" that happen to swim, walk and quack like python classes.
So if I understand your original question right (which I may not), you want to use some sort of mechanism in C to generalize one ExtensionClass type with another *in C*. I don't think this is possible (it might be possible with some sort of C++ mechanism, but I haven't delved into that beast of a language in years...). -Michel
At 05:33 PM 2/24/00 -0800, Michel Pelletier wrote:
So if I understand your original question right (which I may not), you want to use some sort of mechanism in C to generalize one ExtensionClass type with another *in C*. I don't think this is possible (it might be possible with some sort of C++ mechanism, but I haven't delved into that beast of a language in years...).
The method chain of an ExtensionClass type structure can point back to a previous method chain, thus allowing extension of the type. Similarly, the other members of the type structure can point to existing routines. And, as long as one uses a backwardly compatible data structure for the type, one can subclass an existing ExtensionClass. It is usually easier, however, to just create mixin ExtensionClasses for the different bits you need, and combine them together as base classes for a Python class.
"Phillip J. Eby" wrote:
At 05:33 PM 2/24/00 -0800, Michel Pelletier wrote:
So if I understand your original question right (which I may not), you want to use some sort of mechanism in C to generalize one ExtensionClass type with another *in C*. I don't think this is possible (it might be possible with some sort of C++ mechanism, but I haven't delved into that beast of a language in years...).
The method chain of an ExtensionClass type structure can point back to a previous method chain, thus allowing extension of the type.
Ah!
Similarly, the other members of the type structure can point to existing routines. And, as long as one uses a backwardly compatible data structure for the type, one can subclass an existing ExtensionClass.
I see, it's one of those using-C-in-an-OO-way kind of things without there being an explicit language mechanism to get it done.
It is usually easier, however, to just create mixin ExtensionClasses for the different bits you need, and combine them together as base classes for a Python class.
Understood. -Michel
participants (4)
-
James Henstridge -
Michel Pelletier -
Pavlos Christoforou -
Phillip J. Eby