Python isn't just Java without the compile
bitworking.org
bitworking.org
- pg
"About 12 years ago, Python aquired lambda, reduce(), filter() and map(), courtesy of (I believe) a Lisp hacker who missed them and submitted working patches. But, despite of the PR value, I think these features should be cut from Python 3000."
- gvr
Remember: Python's not broken, you are.
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)class NullReceiver(object):
class SimpleCallable(object):
def __call__(self, *args):
pass
def __getattr__(self, name):
print 'unhandled method "%s" called' % name
return nullReceiver.SimpleCallable()s = 'a'
class String
def rghize
return self + 'rgh'
end
endputs s.rghize