We certainly don't want Python to process the data in a way that the database doesn't expect. When I see a potential flaw such as summing an empty list to 0 , should I just keep quiet about it, or let everyone know? It doesn't make sense to me. Probably not, or they wouldn't have shipped it. Having it evaluate to 0 is wrong 99. But DepthToWater may or may not exist for a given event well may be covered with fire ants, for example. Isn't that why we have try:except? I hope that's not too ivory tower. Append str myname except : wx.
Bye, bearophile For max and min, why can't you just add your argument to the set itself? Of course this is not good for summing other types of objects. How should sum deal with that? Happily lambda survived the version 3. By analogy with the above, in the domain of the extended reals, negative infinity is the identity element for the maximum and supremum operators, while positive infinity is the identity element for minimum and infimum. But of course it could have been implemented in a different way. When the sequence is empty, returns start. You can check the length of v before calling max on it.
Any arithmetic expression involving a Null evaluates to Null. I'll drop this from this point on. If there is a mixture of these types, or if other values of other types are passed, a static error is raised. Another question is why this param is empty. I'm fairly certain you can't get 0 from a query that returns no records, so I don't like seeing empty being treated as 0, even if it means that in set theory because databases aren't sets.
Items to compare key optional It refers to the single argument function to customize the sort order. The neutral element for this operation is one. A recursive definition should be for lists where elements can be added, and ignoring pythonic negative indexing : Define 'sum L ' by a. This requires that max empty set be something that's smaller than everything else. The max function returns the one value in the sequence that is greater than any other in the input sequence.
A possible alternative is to add a default to max , like the next built-in of Python 2. The answer is that sum can't deal with that. You've given a good example yourself: the Kriging algorithm needs a Null value which is not zero. Who decides what it is supposed to do if not the author? The flaw is that you provide a recursive definition with no start value, which is to say it is not a recursive definition at all. It is a logical fallacy to equate unknown with 0. The new min and max functions use regular for-loops. I was aware of all that below.
TopOfCasing is usually known and constant until resurveyed. From a mathematical point of view, not that that's directly relevant, it doesn't make much sense to me to add that default argument. What do you set x to? Because it uses itertools, the extension runs at C speed entirely avoiding the eval-loop. Probably they can be useful as sentinels, but in Python I nearly never use sentinels anymore, and they can probably give some other problems. But if it did, it would treat them as zero, since that's the only useful thing and mathematicians are just as much pragmatists as spreadsheet users.
The neutral element for this operation is one. I believe that there have been excessive discussions about this decision, and the current implementation is very good, if not the best. Naturally you always get 0. What's the difference between having 0 widgets in a box and having an empty box with, er, no widgets in it? Isn't it Pythonic to not write a litany of tests to cover every possible case, but instead use try:except? The user must conform to the needs of the database because the other way ain't ever gonna happen. Isn't that why we have try:except? What do Access and Mathematica do? The neutral element for this operation is one.
These standard functions are flexible enough to work on any iterable, be it an in-memory sequence like a list, or a stream generated one element at a time. It's way far from obvious. Best, Laszlo I suppose the following is accepted by statisticians. Now the boss runs out to Joe's Widget Emporium and pays retail only to discover when he gets back that the shipment has arrived containing 12 widgets. Excel's treatment of blank cells is inconsistent with Access' treatment of Nulls and therefore wrong, anyway you slice it. What do you set x to? They could have decided that sum must take at least two arguments, because addition requires two arguments and it's meaningless to talk about adding a single number without talking about adding it to something else.