Re: [Python-3000] NaN in sorting

2008-11-13 Thread Bruce Leban
s the sort key > will make sort do what you want: > > def SortNoneFirstAndNanLast(x): > if x is None: >return (1, x) > if isnan(x): >return (3, x) > return (2, x) > > No need to modify either sort() or <. > > On Thu, Nov 13, 2008 at 11:15 AM, Bruce Leban <[EMAIL PR

Re: [Python-3000] None in Comparisons: None vs. float("inf")

2008-11-13 Thread Bruce Leban
I think the behavior of NaN in comparisons is more confusing: >>> sorted([1,nan,2]) [1, nan, 2] >>> sorted([2,nan,1]) [2, nan, 1] >>> sorted([2,None,1]) Traceback (most recent call last): File "", line 1, in sorted([2,None,1]) TypeError: unorderable types: NoneType() < int() At least the th

Re: [Python-3000] None in Comparisons

2008-11-12 Thread Bruce Leban
On Tue, Nov 11, 2008 at 2:00 PM, Greg Ewing <[EMAIL PROTECTED]>wrote: > M.-A. Lemburg wrote: > >> On 2008-11-11 14:28, Antoine Pitrou wrote: >> >> But why should "n/a" (or "missing", or "undefined") imply "smaller than >>> everything else"? >>> >> >> It's just a convention based on viewing None a

Re: [Python-3000] default argument surprises

2008-08-26 Thread Bruce Leban
On Tue, Aug 26, 2008 at 9:23 PM, James Y Knight <[EMAIL PROTECTED]> wrote: > On Aug 27, 2008, at 12:14 AM, Chris Monson wrote: > >> >> And I think that metaphor is easy to read. Chains of else operators can be >> useful: >> >> x = f() else g() else h() else 0 >> >> Not a bad idea. Looks like th

Re: [Python-3000] default argument surprises

2008-08-26 Thread Bruce Leban
There are two issues** here: (1) def foo(L=[]): the [] is a single list, not a new list created every time the function is called. (2) def foo(L=list()): the list() is evaluated once when the function is declared. I think (1) is easy to explain; I find (2) confusing. (**Yes, I realize that these

Re: [Python-3000] PEP 3101 str.format() equivalent of '%#o/x/X'?

2008-06-06 Thread Bruce Leban
It seems somewhat illogical to require [#][sign] in that order when the parts inserted by them go in the opposite order. So if a specific order is required, then I think it should be reversed. '=' padding goes in the wrong order too: perhaps -#0=20d makes more sense than 0=-#20d. I don't find tha