A better self
Huaiyu Zhu
huaiyu at gauss.almadan.ibm.com
Wed Jul 10 13:00:45 EDT 2002
Sean 'Shaleh' Perry <shalehperry at attbi.com> wrote:
>>
>> Before you all react (programmers can be SO conservative), please think
>> about it!
>>
>
>I have played with ideas like this in python and other languages, and witnessed
>others do the same.
>
>.foo is REALLY hard to see if the font is not just right.
>
>.size = .r + .l
>
>is even worse.
>
>I am not 100% against the idea as an idea, but the actual usage is not all that
>fun.
A better (and currently available) convention is
_.size = _.r + _.l
It has been mentioned several times in this thread. I've used it several
times in the past and liked it, esp in iterative algorithms. Some usage
patterns include
def __init__(_, x, y, z):
_.x, _.y, _.z = x, y, z
def process(_, x, y, z):
actions involving _.x, _.y, _.z, x, y, z
_.x, _.y, _.z = x, y, z
def update(_):
x, y, z = _.x, _.y, _.z
actions involving x, y, z
_.x, _.y, _.z = x, y, z
One could even think of _. as a magic persistence prefix that makes the
variable keep its value between method calls. It is also easy to replace
_.x with self.x or vice versa in a good editor.
Huaiyu
More information about the Python-list
mailing list