4 ms·
This 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 t
by jlujan 18y ago
This 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)