Prothon is switching to the .NET platform

John Roth newsgroups at jhrothjr.com
Tue Aug 10 22:02:01 CEST 2004


"Christopher T King" <squirrel at WPI.EDU> wrote in message
news:Pine.LNX.4.44.0408101527020.9982-100000 at ccc2.wpi.edu...
> On Fri, 6 Aug 2004, John Roth wrote:
>
> > The place where this gets really ugly is inserting functions
> > into the instances. They have to be created at the module
> > level, and then inserted into the instance by a module level
> > function (somewhat similar to the way classmethod,
> > staticmethod and property work).
>
> Oh, I wouldn't even attempt that until Python supported
> "def object.method():" syntax (like Prothon does).

It actually works quite nicely. Your suggested syntax
would be a definite plus, but I'm not holding my breath
until there are a number of people using some variety
of prototype package in Python. It's a classic chicken
and egg problem.

Hans Nowak's package works quite well, although
it uses self-style objects: they don't start out with
any kind of inheritance, you have to plug in the
objects you want as parents after creating the
instance.

On the other hand, it could simply be waiting
on someone writing a PEP and giving some
believable use cases for wanting to insert
random methods into instances.

> Using my derive class,
> you could acheieve a similar effect though:
>
>  class my_derived_class(derive):
>      def some_new_function(self):
>          <do stuff>
>  my_derived_object = my_derived_class(my_prototype_object)
>
> You aren't able to insert function definitions after the derived object is
> created using this method (something I imag, but most function
> definitions are premeditated anyways.

I'm not familiar with your system, but there's no particular
difficulty inserting methods into either a class or an instance.
You just have to know the correct way to wrap it.

To put it into an instance, you have to wrap it in new.instancemethod.

John Roth
>





More information about the Python-list mailing list