Chris, There is much to say about consistent behavior as compared to flexibility and convenience.
I have seen other languages provide functions for example, where the result can vary and often cause confusion. R had a function that would sometimes notice the result could be simplified and return that. Guess what? It caused lots of problems and an option was added that said it should NOT simplify and always return the same kind of thing. Consider what happens if a calculation that returned a matrix would decide that is there was only one columns, it would return a vector/array/whatever as a one-dimensional result and if the calculation produced a 1 by 1 matrix, it would simply return a scalar value! But it may be a feature you want in some cases, albeit rarely when the results of the function are fed into something that is not expecting it. Various forms of polymorphism can be helpful but can also be very confusing. Some solutions are what I have described in earlier messages and some languages blur distinctions. Again, in R, there may not be a scalar as all you have is a vector of length one. But matrices even of 1-D are not vectors and I have had to interconvert between them to make some code run. I am not making comparisons in the sense that nothing other languages choose to do is binding on what Python should do. Still, I think it is wrong to suggest that it does not often do partially ambiguous things from some perspective. Many functions will take a variety of arguments and return something reasonable but different each time. As a dumb example, what does a simple function like max() return if fed just integers, just floating point or a combination of both? It seems to return whatever type the maximum indicates. But it also accepts characters and sorts them appropriately returning type 'str' and probably accepts and returns all kinds of objects if you specify a key function. Is that so much different than we are discussing in that there isn't any absolute consistency and things can go various ways in terms of return value? Heck, I can even make max() return None! -----Original Message----- From: Python-list <python-list-bounces+avi.e.gross=gmail....@python.org> On Behalf Of Chris Angelico Sent: Saturday, December 31, 2022 10:23 PM To: python-list@python.org Subject: Re: NoneType List On Sun, 1 Jan 2023 at 14:19, <avi.e.gr...@gmail.com> wrote: > Had a language like that been created today, I wonder if some designs > might have looked a bit different so that some functions could be > called with optional arguments that specified what the user wanted returned. Frankly, I doubt it. While you can argue "returning self is more useful" vs "returning None is more clear if you get it wrong", having options does NOT improve things, and just makes everything more complicated, slower, harder to comprehend, and generally worse to work with. A language should have some sort of consistent behaviour and stick to it. If that's not possible, an object type should at least have that. ChrisA -- https://mail.python.org/mailman/listinfo/python-list -- https://mail.python.org/mailman/listinfo/python-list