From: Paul Prescod Date: 2002-09-06T02:00:40+09:00 Subject: Re: Ruby aesthetics On Thu, 5 Sep 2002, William Djaja Tjokroaminata wrote: > Of course, because Ruby follows Eiffel's function call model > (indistinguishable data access and function call, at least from user's > perspective, by making the parentheses optional), in Ruby @data1 and > self.data1 are different. Now I don't remember if Python can do the > "func=" form. In other words, if in Ruby we write > > def func (arg1, arg2, ...) > self.data1 = arg1 # access through accessor function > .... > > can we do this in Python? > > def func (self, arg1, arg2, ...) > self.data1 () = arg1 # ???? syntax error ???? > # probably should be the classic way: > self.data1 (arg1) # access through accessor function Python has two separate concepts of attribute-syntax and method call syntax. But you can make code that looks like it is writing to attributes really call methods (and of course a method can provide access to attributes). So you wouldn't write "self.data1() =" but "self.data1 =". If there is an accessor for data1 then it will call it. Otherwise it will just write to the instance dictionary. Paul Prescod