Python for Ruby Programmers (LA RubyConf 2013)
speakerdeck.com
Python for Ruby Programmers (LA RubyConf 2013)
1–10 of 54 posts
Re: Python for Ruby Programmers (LA RubyConf 2013)
#2Re: Python for Ruby Programmers (LA RubyConf 2013)
#3Re: Python for Ruby Programmers (LA RubyConf 2013)
#4Re: Python for Ruby Programmers (LA RubyConf 2013)
#5 class Test(object):
pass
t = Test()
def test(self):
print('ehlo')
Test.test = test
t.test()
This is rarely done in practice, however (at least, as far as I can tell)Re: Python for Ruby Programmers (LA RubyConf 2013)
#6For example, he mentions Python doesn't have an equivalent of method_missing -- it's technically true that there's nothing you define on a Python class to specifically intercept a nonexistent method, but that's because Python's standard facility for this operates more generally at the level of attribute access. Suspect there's a bit too much expectation of Python to be message-passing like Ruby in not seeing that one.
Similarly, Python has plenty of metaprogramming features, they're just implemented differently -- and from a different conceptual standpoint -- than Ruby's. And so on and so forth.
Re: Python for Ruby Programmers (LA RubyConf 2013)
#7Not bad, but the big weakness is that the author seems to be very familiar with more expert-level aspects of Ruby, but not so much with Python. And turns that into "Python doesn't have these". For example, he mentions Python doesn't have an equivalent of method_missing -- it's technically true that there's nothing you define on a Python class to specifically intercept a nonexistent method, but that's because Python's…
Re: Python for Ruby Programmers (LA RubyConf 2013)
#8Re: Python for Ruby Programmers (LA RubyConf 2013)
#9The presentation states that tuples are “immutable lists“ and that they ”should be homogeneous, but [this is] not enforced“. I disagree: tuples are meant to act as “records“ (as in a database or other set of data), which are neither lists nor homogeneous.
The presentation brought up multiple times filter and map. An article by Guido in 2005 [1] argued that these tools should be cut from Python 3. While they still exist, I am under the impression it is considered more Pythonic to use list comprehensions in the place of filter and map, as stated in the article.
Python not having define_method is misleading. One can define a method of a class as one would any attribute of the class [2]. However, it is far easier to dynamically define a method in Ruby than in Python, because lexical scoping is inherent to a Ruby block but not a Python loop.
Python not having method_missing is wrong. One can simply override __getattr__ and return the appropriate function [3].
[1]: http://www.artima.com/weblogs/viewpost.jsp?thread=98196