Getting rid of "self."

BJörn Lindqvist bjourne at gmail.com
Fri Jan 7 17:51:13 CET 2005


Thank you for your replies. But they don't deal with my original
question. :) I have read the thousands of posts all saying "self is
good" and they are right. But this time I want to be different m-kay?
I figure that there might be some way to solve my problem by doing
this:

.def instancevar2locals(method):
.    # Do something magic here so that exec(magic()) is automagically
run each time
.    # the function is invoked.
.    newmethod = method
.    return newmethod

And then in the class definition something like this:

.class A:
.    def __init__(self):
.        self.hi = "hi"
.    def meth(self):
.        print hi
.    meth = instancevar2locals(meth)

But beyond that, I have no idea and I would be grateful if someone
would like to help me with it.
-- 
mvh Björn



More information about the Python-list mailing list