a Python person's experience with Ruby

Steve Howell showell30 at yahoo.com
Sun Dec 9 19:16:14 EST 2007


--- Bruno Desthuilliers
<bdesth.quelquechose at free.quelquepart.fr> wrote:

> Steve Howell a écrit :
> (snip)
> > 
> > Jordan and others, thanks for all your posts; I am
> > learning a lot about both languages.
> > 
> > This is what I've gathered so far.
> > 
> > Python philosophy:
> >    passing around references to methods should be
> > natural (i.e. my_binary_op = math.add)
> >    calling methods should be explicit (use parens)
> >    the use of setters/getters varies among Python
> > programmers; properties, decorators, special
> methods,
> > etc. can be used judiciously to affect the
> interface
> 
> You can forget decorators here - the examples in
> this thread were mostly 
> tricky ways to define properties. To be more
> general, the Python way to 
> implement transparent computed attributes is to hook
> into the lookup 
> mechanism, usually thru the descriptor protocol (the
> property class 
> being one possible implementation), but also using
> the __getattr__ / 
> __getattribute / __setattr__ hooks.
>

Ok, that makes sense.
 
> > Ruby philosophy:
> >    a method itself should be callable without
> parens
> >    you can get a reference to a chunk of code, but
> > then you need a little extra syntax, beyond just a
> > variable name and parens, to eventually call it
> > (yield, &, call, etc.)
> >    when referring to methods, you can use :symbols
> to
> > name the method you're interested in without
> actually
> > calling it
> > 
> > My personal experience:
> > 
> (snip)
>  >
> >    I was surprised in Ruby by how seldom I really
> pass
> > references to methods around,
> 
> This probably has to do with this nice feature named
> 'blocks' !-)
> 

Partly.  It's also due to the fact that my experience
so far in Ruby has mostly been writing code at the top
layer of a fairly vanilla Rails MVC app, whereas in
Python I've done a much wider variety of tasks.




      ____________________________________________________________________________________
Be a better friend, newshound, and 
know-it-all with Yahoo! Mobile.  Try it now.  http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ 




More information about the Python-list mailing list