On Thu, Dec 16, 2010 at 2:12 PM, M Daoust
A hack could be done today to have these behave as both functions and properties by having the property return a callable bool derived class that returns itself. But that seems a bit too cool yet gross...
That could break existing code. Suppose someone has something like f = random.choice([s.isalpha, None, s.isdigit]); truthiness = f() if f else f. OK, the random choice part is dumb, but I can see someone doing a test where they assume that methods like .isdigit will always return True and using that as a replacement for callable().
Well it it doesn't sound that odd to me. This it's one of the (few) things I miss from Matlab. Not that parentheses are optional for function calls, but that 'true', 'false', 'Inf' and 'NaN' act both as their respective values, and as functions. Like 'ones' and 'zeros' they can be called with a size tuple to get an array of nd-array of that value.
What's the advantage over [True] * n? Seems like a limited usecase, especially since the people who are really serious about arrays (vs. lists) are going to be using one of the numpy array classes. -- Carl