Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I don't think Python's approach is particularly more elegant than JavaScript, as they both distinguish property-as-value and property-as-function. It's just a matter of where to put property-as-function (and unlike Python, JavaScript can have non-configurable properties which can be optimized). As property-as-function can subsume property-as-value, no built-in property-as-value would be truly elegant (Ruby is close, but not exact).


I agree. Python's descriptor pattern was an endless source of confusion for me. But, it's much easier to do mixins in Python than in JS, even if the mro algorithm is a bit complicated...


Sorry, could you clarify what you mean by “distinguish property-as-value and property-as-function“? How does Python distinguish between these two?


The very descriptor protocol exists to distinguish property-as-function (descriptor) from property-as-value (slot).




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: