Survival of the fittest

baalbek rcs at bgoark.no
Wed Sep 27 17:33:25 EDT 2006


James Stroud wrote:
> baalbek wrote:
>> Why? The language is just so well designed (I miss some of Ruby's 
>> features, but then, nothing is perfect)
> 
> Out of curiosity, what are these features that ruby has that python 
> lacks. 

Code blocks (closures), that are more advanced than Python's Lambdas, 
and the use of yield.

Also, you can pass code blocks to every method without any special 
syntax for the method ( it is up to the method of checking whether there 
is a code block being passed ).

Some syntactic sugar (list.each { |i| puts i }, etc).

A very simple syntax for reading/writing properties (attr_accessor 
:prop1 automatically creates set/get methods for the property prop1).

Also, a standard way of method names that automatically enforce rules, f.ex:

def hascolor?
    ---
end

The question mark automatically enforces the method to return boolean.

Or:

def prop1=
   ---
end

automatically assigns to the property @prop1 whatever is evaluated in 
the method.

And some other things I can't recall at the moment.


Baalbek



More information about the Python-list mailing list