3 ms·
The example given in the articles entirely fails to describe functions as being first-class citizens. Python also lacks full continuations, unless the article i
by k4st 18y ago
The example given in the articles entirely fails to describe functions as being first-class citizens. Python also lacks full continuations, unless the article is referring to Stackless Python. What is described in the article as continuations are actually generators. Finally, the meta-programming described in the article, while valid, really only scratches the surface of what's possible with meta classes in Python.
- jlujan 18y agoThis article is a poorly done "look how smart I am". First, the title makes little sense. If you were going to compare and contrast Python to Java, this first thing to come to mind would be static typing, not a compile step. Second, I was going to complain about the first-class functions as well. By his example, PHP has first class functions as well because you can define a function out side of a class. But we all know PHP does not, in fact, have first class functions because you cannot pass a function as an argument or return a function as a value from another function in PHP. I think you can get the point across better with this example... def fun_factory(scale): def inner_func(arg1,arg2): return scale * ( arg1 + arg2) return inner_func class myclass(object): def __init__(self,scale_func): self.better_example = scale_func if __name__ == "__main__": print fun_factory(10)(5,5) myinst = myclass(fun_factory(10)) print myinst.better_example(5,5)