Prothon, metaclasses, Zope [Was: A 'Python like' language]

Mark Hahn mark at prothon.org
Thu Apr 1 01:23:41 EST 2004


"Greg Ewing (using news.cis.dfn.de)" <ieyf4fu02 at sneakemail.com> wrote in
message news:c4dkg2$2gsuda$1 at ID-169208.news.uni-berlin.de...
> Mark Hahn wrote:
> > > But presumably he wants the check done only once, when a subclass is
> > > defined, *not* every time said subclass is instantiated.
> >
> > You can have a different __init__ for an object and it's prototpe.So the
> > Prothon equivalent of a subclass can easily have different __init__
> > behaviour than it's child (what you call instance).
>
> Can you post some code illustrating how you would do this
> in Prothon? I still can't see how, at the point where you
> do
>
>    X = Base()
>
> anything can tell whether you're intending to use X as
> an instance of Base or whether you're going to go on to
> say
>
>    with X:
>      def ...
>
> and use X as a prototype which inherits behaviour from
> Base. In both cases, Base.__init__ is going to get invoked
> before you have a chance to define any other __init__ that
> might override it.

You don't have to use the obj = proto() technique to create an object.  The
following code is identical to saying subproto = topproto() except no
__init__() will be called:

   subproto = Object()
   subproto.set_proto(topproto)  # switch prototype on the fly

Does this give you the missing piece you need or is there something else
missing in Prothon?  If you explain the overall goal better I'll write the
complete code for you.

>
> -- 
> Greg Ewing, Computer Science Dept,
> University of Canterbury,
> Christchurch, New Zealand
> http://www.cosc.canterbury.ac.nz/~greg
>





More information about the Python-list mailing list