I couldn\'t find anything on this subject on Google, so I think I should ask it here:
Is it possible to chain functions with Python, like jQuery does?
Take a look at this. It is A simple wrapper class for chaining. And it implemented some of the underscore.js lib's functionality. You wrap your list, tuple or dict with an underscore, and play with it then get the value out of it by appending another underscore.
print (_([1,2,3])
.map(lambda x: x+1)
.reverse()
.dict_keys(["a", "b", "c"])
.invert()
.items()
.append(("this is what you got", "chaining"))
.dict()._)
output:
{2: 'c', 3: 'b', 4: 'a', 'this is what you got': 'chaining'}