Prothon is switching to the .NET platform

John Roth newsgroups at jhrothjr.com
Mon Aug 9 14:33:28 EDT 2004


"John Roth" <newsgroups at jhrothjr.com> wrote in message
news:10hc6mk55u0qq26 at news.supernews.com...
>
>
> Hans Nowak just sent me a private e-mail pointing out that he
> had done a Self-style implementation about a year ago. It looks
> interesting, especially since it uses getattr and setattr rather than
> getattribute. The trick with functions seems to be to use
> new.instancemethod. Otherwise the code looks to be very
> straightforward. __setattr__ just makes a couple of type
> checks, insures that instances ending in _p are from the
> selfish class, wraps functions in new.instancemethod and
> rewraps methods likewise. __getattr__ implements the
> inheritance rules.

It does, by the way, work quite nicely. I just implemented
"Cloak of Darkness" (which is the text adventure game that
Roger Firth uses to assess the difficulty of writing in new
interactive fiction authoring systems) in a couple of hours
using TDD. The only significant problems I ran into were
due to lack of support in Python itself - the package worked
flawlessly.

The biggest issue was that it violated one of the fundamental
assumptions in unittest - since everything is initialized at
module load time, each test does *not* see a fresh copy
of object instances.

I also forgot several times to bind functions to the
objects - the same problem that people have with
staticmethod and classmethod that decorators are
supposed to fix.

This is one of the domains where a prototype based
object system shines: every object in the game is otherwise
a singleton that needs its own class!

John Roth
>





More information about the Python-list mailing list