Description
As it is now, the field_size_limit
method from the csv
module does the following, as per the documentation (emphasis mine):
Returns old limit. If limit is not given, no new limit is set and the old limit is returned
It seems to me this is a major discrepancy with the majority of such methods I’ve encountered, which usually return the current value (thus the “new” value, if it is a setter). (I am talking about my experiences with such methods “in the wild”, not specifically in this module).
Am I the only one mildly annoyed at this? Or, more probably, is there an explanation to this way of operating that I haven’t thought of?
More elements
This was initially posted as an issue, but @picnixz correctly redirected me here. On further consideration, this indeed seems a better platform to interact on this topic.
In addition to pointing me here, they also made the argument that in the case of a temporary change in field size limit, the current way of operating was shorter to write:
old = obj.set_value(new)
# do something with new
...
# restore
obj.set_value(old)
instead of:
old = obj.get_value()
obj.set_value(new)
# do something with new
...
# restore
obj.set_value(old)
Though it is technically true, it in itself does not seem to me a satisfactory justification. The way this operates really seems counter intuitive and removing one line of code in a specific instance doesn’t outweigh the counter intuitiveness in this instance (for me).
Main problem
I would have proposed to change this to match the expected behavior of this type of methods, but @tjreedy made the point that it wasn’t such a big issue, while necessitating a breaking change to be fixed.
Question
Am I the only one for who it is a strange way of doing this operation? Is there a pattern I have not encountered, or a reason to justify this I wouldn’t have seen?
I am aware this is minor and not really worthy of a breaking fix but I’d still like to have your opinions on this.