Re:What's better about Ruby than Python? - comp.lang.python
by etal on Friday August 27, 2010 @10:21AM
(#1638876)
Not disagreeing with you. In fact, the first example is one reason why "print" was changed from a keyword to a function in Python 3:
myfunc <- lambda x: (print x) or x*x # SyntaxError
myfunc <- lambda x: print(x) or x*x # OK in Py3
Re:What's better about Ruby than Python? - comp.lang.python
by llimllib on Friday August 27, 2010 @08:46AM
(#1638632)
> The other thing is that Python has no concept of context
Rather, I'd say that part of the zen of python is: implicit is better than explicit, and I prefer python's behavior in this instance.
Re:What's better about Ruby than Python? - comp.lang.python
by nuclear_eclipse on Friday August 27, 2010 @09:21AM
(#1638716)
You've got that backwards for Python: Explicit is better than implicit.
The other thing is that Python has no concept of context. In Ruby, I can type:
And it will execute foo(x) for the containing object. In Python, the closest equivalent would be: This syntax difference may seem trivial, but it allows you to do some very interesting things to classes. For instance: Now the class Bar has a method called "x", without us needing to explicitly define it.Ruby's instance_eval method extends this further, allowing you to execute a block of code in the context of any object you wish.