3 ms·
I love Python, I really do, but JavaScript happens to be slightly better as a browser language because it is a little freer with the anonymous functions. Most J
by postfuturist 16y ago
I love Python, I really do, but JavaScript happens to be slightly better as a browser language because it is a little freer with the anonymous functions. Most JavaScript programmers use this all the time, without even thinking. Here's a jQuery example:
$.ajax({
url: 'ajax/test.html',
success: function(data) {
$('.result').html(data);
alert('Load was performed.');
}
});
The equivalent Python would be this (assuming you ported jQuery):
def successcb(data):
Q('.result').html(data)
alert('Load was performed
Q.ajax(url='ajax/test.html', success = successcb)
OK, that's not too bad, I guess. Named parameters are nice. Having to define the success callback separately is not so great.
Edit, HN broke the formatting.