3 ms·
Agreed. Even if these two pieces of code might accomplish the same thing, at least the Python version doesn't make me want to stab myself in face whenever I wri
by stevenwei 16y ago
Agreed. Even if these two pieces of code might accomplish the same thing, at least the Python version doesn't make me want to stab myself in face whenever I write it:
Invoking an object callback in PHP:
call_user_func_array(array($object,'method_name'),array($arg1,$arg2,$arg3));
Invoking an object callback in Python:
object.method_name(arg1,arg2,arg3)
(Python's *args and **kwargs are especially useful in these types of situations.)
Although PHP is slowly adding useful modern language features (lambdas, closures), some of the syntax really is terrible. I honestly can't imagine anyone preferring the former to the latter, at least in this example.