3 ms·
While I do see the usefulness for the specific example, and while it does seem to reduce boilerplate which is really nice, how useful it is outside of the Point
by yladiz 10y ago
While I do see the usefulness for the specific example, and while it does seem to reduce boilerplate which is really nice, how useful it is outside of the Point3D example? For example, how often do you actually gt/lt comparisons between classes, or equate classes when they're not mathematical constructs like this? And if you add an attribute that shouldn't be used in repr or comparison, you have to explicitly say that in the attribute declaration, meaning it's would be much less clear what's going on down the road -- as in it won't be apparent how the comparison works or why this is being printed the way it is -- which I don't like in a language like Python. It almost seems like you're trading language level boilerplate for this library's boilerplate, and while it may be less with this library it obfuscates what's going on at the expense of more explicit code.
I can kind of understand something like this in Ruby, as it kind of encourages this (and it also has nicer class string-ification by default), but in Python I'd rather have all of my logic be explicitly stated out at the expense of less boilerplate. Also how often do you really need to overwrite those gt/lt methods in production code? If I saw that, rather than an explicit e.g. `.gt` method, I'd consider that a code smell.