a Python person's experience with Ruby

Bruno Desthuilliers bdesth.quelquechose at free.quelquepart.fr
Sat Dec 8 18:11:23 EST 2007


Steve Howell a écrit :
> --- Bruno Desthuilliers
> <bdesth.quelquechose at free.quelquepart.fr> wrote:
> 
> 
>>Colin J. Williams a écrit :
>>
>>>I'm not sure that I like add 3, 5, 7
>>>
>>>but it would be nice to be able to drop the
>>
>>parentheses
>>
>>>when no argument is required.
>>>
>>>Thus:         close;
>>>could replace close();
>>
>>This just could not work given Python's object
>>model. The parens 
>>actually *are* the call operator.
>>
> 
> 
> I mostly agree with you, but in the specific use case
> of having just a single token on a line, you could
> argue that Python could DWIM on calling an object if
> the object is callable, since otherwise it's just a
> no-op. 

It's not. If the name is not defined, it raises an exception (either a 
NameError or an AttributeError). And if the name resolves to a computed 
attribute, the getter for this computed attribute will be invoked - with 
possible side effects.

> I think the argument against doing that is
> more based on explicit-vs.-implicit principle versus
> actual constraints of the object model.

I'd say that the object model being the work of a strong proponent of 
the explicit-vs.-implicit principle, it's probably another 
chicken-and-egg problem - so we are both right here !-)

> Another aspect of Ruby is that the final expression
> evaluated in a method actually gets returned as the
> result of a method,

Unless there's an explict return before...

> which has further implications on
> whether "close" is simply evaluated or called.

I'm sorry but I'm not sure I get the point here.



More information about the Python-list mailing list