Confessions of a Python fanboy

Bruno Desthuilliers bruno.42.desthuilliers at websiteburo.invalid
Tue Aug 4 04:03:53 EDT 2009


Steven D'Aprano a écrit :
> On Fri, 31 Jul 2009 13:38:56 +0200, Bruno Desthuilliers wrote:
> 
>>> On the other hand, we don't have to prefix names with @ and @@,
>> Nope, we have to prefix them with 'self' or 'cls' (or even
>> 'self.__class__').
> 
> Incorrect.

Correct for all relevant cases, except this one:

>>>> class K:
> ...     class_attribute = 'No @@ required.'
> ...

>>>> K().class_attribute
> 'No @@ required.'

Once again: Ruby's attributes are *private*, so you can't access an 
attribute (class or instance) from outside a method. IOW, the above 
example is irrelevant.

(snip)

> Disadvantages: your code is filled with line noise. It's an arbitrary 
> choice between @@ meaning instance attribute and @@ meaning class 
> attribute -- there's no logical reason for choosing one over the other, 
> so you have to memorise which is which. It's easy to get it wrong.

So far that's something I have no difficulty living with.

>>> and we
>>> don't have the compiler trying to *guess* whether we're calling a
>>> function or referring to a variable.
>> Please re-read a bit more carefully - it's *all* method call. 
> 
> What did I misread from here?

Nowhere - it's me that got it wrong here, sorry.

(snip)


>>> Somebody who knows more Ruby than me should try writing the Zen of
>>> Ruby. Something like:
>> (snip childish parody of Python Zen)
>>
>> Steven, is that any useful ?
> 
> It made me feel good.

Why ???

You don't like Ruby ? Fine, don't use it. Period. I can't see the point 
of all these pissing contests.

> But seriously, while I admit that I have very little Ruby experience, and 
> so aren't in a great position to judge, it seems to me that Ruby doesn't 
> have anything like Python's over-riding design principles (the Zen). If 
> there is a design principle to Ruby, I can't see what it is.

Fullfill the tastes of Matz ?-)

(snip)

>>> Although I'm sure Ruby has its good points. I'm not convinced anonymous
>>> code blocks are one of them though.
>> Ruby's code blocks come from Smalltalk, where they are an absolute
>> necessity since message passing (which code blocks are part of) is the
>> *only* builtin control flow in Smalltalk - so you just *need* this
>> construction to provide branching and iterations.
> 
> Just because Smalltalk had a particular (mis?)feature

You can drop the 'mis' part IMHO. The point of code blocks in Smalltalk 
is that once you have something as powerful as the message+code blocks 
combo, you just don't need any other 'special form' for control flow.

> doesn't mean that 
> other languages should copy it.

Nope. But OTHO, Python is famous for all the features it copied from 
other languages !-)



More information about the Python-list mailing list