Partial 1.0 - Partial classes for Python

Carl Banks pavlovevidence at gmail.com
Wed Feb 7 10:37:45 EST 2007


On Feb 7, 10:17 am, "Carl Banks" <pavlovevide... at gmail.com> wrote:
> On Feb 7, 8:51 am, Thomas Heller <thel... at ctypes.org> wrote:
>
>
>
> > Martin v. Löwis schrieb:
>
> > > I'm happy to announce partial 1.0; a module to implement
> > > partial classes in Python. It is available from
>
> > >http://cheeseshop.python.org/pypi/partial/1.0
>
> > > A partial class is a fragment of a class definition;
> > > partial classes allow to spread the definition of
> > > a class over several modules. One location serves
> > > as the original definition of the class.
>
> > > To extend a class original_module.FullClass with
> > > an additional function, one writes
>
> > > from partial import *
> > > import original_module
>
> > > class ExtendedClass(partial, original_module.FullClass):
> > >      def additional_method(self, args):
> > >          body
> > >      more_methods
>
> > > This module is licensed under the Academic Free License v3.0.
>
> > > Please send comments and feedback to mar... at v.loewis.de
>
> > Nice idea.
>
> Indeed.  I was going to make a post asking for advice on high-level
> delegation (basically you have a generic mostly-OO framework, which
> the user extends mostly by subclassing, but how do the generic classes
> know about the user-extened classes?).  I knew of many solutions, but
> all had significant drawbacks.  But this seems like it'd work great,
> maybe with a few minor inconveniences but nothing like the icky hacks
> I've been using.
>
> Ironic, since I myself posted a very simple example of how to do this
> with a class hook here on c.l.python a while back.

And looking back at that post, I said that using such a hack would be
"truly evil".  To every thing there is a season....


Carl Banks




More information about the Python-list mailing list