Confessions of a Python fanboy
bruno.42.desthuilliers at websiteburo.invalid
Fri Jul 31 13:38:56 CEST 2009
Steven D'Aprano a écrit :
> On Thu, 30 Jul 2009 18:47:04 +0100, Tim Rowe wrote:
>> That and the fact that I couldn't stop laughing for long enough to learn
>> any more when I read in the Pragmatic Programmer's Guide that "Ruby,
>> unlike less flexible languages, lets you alter the value of a constant."
>> Yep, as they say "Bug" = "Undocumented feature"!
> That's no different from Python's "constant by convention".
Well, at least Python doesn't pretend to have real symbolic constants -
we all know it's only a convention !-)
> We don't even
> get a compiler warning!
Of course - from the compiler's POV, it's only usual rebinding.
> 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
> 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. Python is
'uniform' in obj.name is always an attribute lookup (methods being
attributes), Ruby is uniform in that 'obj.name' is always a method call.
> 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 ?
> 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.
Wether it makes sense to have code blocks in Ruby is another question
since Ruby does provide traditional control flow features, but then one
could question Python's "lambda" (hem...) too.
More information about the Python-list