IWETHEY v. 0.3.0 | TODO
1,095 registered users | 0 active users | 0 LpH | Statistics
Login | Create New User
IWETHEY Banner

Welcome to IWETHEY!

New Like this:
\nclass UpperClassTwit(object):\n    def __getattribute__(self, name):\n        print 'trying %r.%s' % (self, name)\n        try:\n            parrot = object.__getattribute__(self, name)\n        except:\n            print 'not found: %r.%s' % (self, name)\n            return self.hidey_ho\n\n        return parrot\n\n    def hidey_ho(self):\n        print 'oog'\n\nf = UpperClassTwit()\n\nf.garble()\n

Running this yields:
\n>>> ## working on region in file /usr/tmp/python-1260iBu...\ntrying <__main__.UpperClassTwit object at 0x81de63c>.garble\nnot found: <__main__.UpperClassTwit object at 0x81de63c>.garble\ntrying <__main__.UpperClassTwit object at 0x81de63c>.hidey_ho\noog\n>>> \n
Regards,

-scott anderson

"Welcome to Rivendell, Mr. Anderson..."
New :) I haven't "gone meta" enough yet, I see...
"There's a set of rules that anything that was in the world when you were born is normal and natural. Anything invented between when you were 15 and 35 is new and revolutionary and exciting, and you'll probably get a career in it. Anything invented after you're 35 is against the natural order of things."

Douglas Adams
New I came up with this ...
Here's what works ...
class BoundCall:\n    def __init__(self, name):\n        self.name = name\n    def __call__(self, *args):\n        print 'Calling %s%s on me' % (self.name, str(args))\n\nclass Echo(object):\n    def __getattribute__(self, name):\n        return BoundCall(name)\n
This is pretty close to what I was thinking. There might be a few differences w.r.t. predefined methods in Object, but that's ok.

I had to download Python 2.3 for this to work, so I guess that makes pre-2.3 python a FOO language and post-2.3 MOO.

Thanks.
--
-- Jim Weirich jweirich@one.net [link|http://onestepback.org|http://onestepback.org]
---------------------------------------------------------------------
"Beware of bugs in the above code; I have only proved it correct,
not tried it." -- Donald Knuth (in a memo to Peter van Emde Boas)
New I ran mine in 2.2.3, FYI
I think __call__ is new in 2.3.
Regards,

-scott anderson

"Welcome to Rivendell, Mr. Anderson..."
New My 2.2 is evidently broken
I thought __call__ had been available for some time, but what do I know.

I discovered my python2.2 installation is broken. It was silently swallowing the script without any output. Turns out that it is not the script's problem, 2.2 is is silently swallowing everything. I should probably just uninstall it (why does my system have 3 versions of python anyways).

--
-- Jim Weirich jweirich@one.net [link|http://onestepback.org|http://onestepback.org]
---------------------------------------------------------------------
"Beware of bugs in the above code; I have only proved it correct,
not tried it." -- Donald Knuth (in a memo to Peter van Emde Boas)
     MOO/FOO and Python - (JimWeirich) - (11)
         Having done this before... - (admin) - (10)
             I'm not sure that's what I mean - (JimWeirich) - (9)
                 Like this: - (admin) - (4)
                     :) I haven't "gone meta" enough yet, I see... -NT - (FuManChu)
                     I came up with this ... - (JimWeirich) - (2)
                         I ran mine in 2.2.3, FYI - (admin) - (1)
                             My 2.2 is evidently broken - (JimWeirich)
                 AFAICT that hinges on method_missing... - (FuManChu)
                 You could also do this: - (admin)
                 Coming at it from the other way - (johnu) - (1)
                     Adding new methods in Ruby - (JimWeirich)

I know kung fu.
131 ms