Confessions of a Python fanboy

Masklinn masklinn at masklinn.net
Thu Jul 30 13:10:35 EDT 2009


On 30 Jul 2009, at 18:31 , Falcolas wrote:
> On Jul 29, 9:06 pm, r <rt8... at gmail.com> wrote:
>
>> 1.) No need to use "()" to call a function with no arguments.
>> Python --> "obj.m2().m3()" --ugly
>>   Ruby --> "obj.m1.m2.m3"  -- sweeet!
>> Man, i must admit i really like this, and your code will look so much
>> cleaner.
>
> I personally would not prefer this, and would likely continue to use
> (), precisely for code clarity - let me explain:
>
> foo.nextval
> foo.val
> foo.previousval
>
> Which of the calls above referenced instance variables
Well, that's very simple: none of them. In Ruby (as in Smalltalk),  
public instance variables simply don't exist.

> and which ones called functions which changed the internal state of  
> foo?
That you can't say, but neither can you say in Python as they could  
all be properties. And of course just because it's a method doesn't  
mean it mutates the object.

> I would have
> trouble saying, just based on the calls above. I would have to go back
> to the definition or documentation of foo to identify which is doing
> what. On the other hand, the following gives a better clue as to what
> is happening (granted not perfect, but better):
Well... it doesn't give much of a clue no really.



More information about the Python-list mailing list