Expression can be simplified on list

Rustom Mody rustompmody at gmail.com
Wed Sep 14 03:16:06 EDT 2016


On Wednesday, September 14, 2016 at 10:23:12 AM UTC+5:30, Steven D'Aprano wrote:
> On Wednesday 14 September 2016 13:59, Lawrence D’Oliveiro wrote:
> 
> > On Wednesday, September 14, 2016 at 2:25:48 PM UTC+12, Ben Finney wrote:
> >> Lawrence D’Oliveiro writes:
> >> 
> >> > It would be better if all such conversions were explicit
> >> 
> >> Why? It's entirely unambiguous ...
> > 
> > <http://lwn.net/Articles/590299/>
> 
> 
> *shrug* 
> 
> And if somebody designed an iterator that behaved badly or surprisingly, would 
> you conclude that the entire concept of iteration is therefore broken?
> 
> The midnight gotcha was (it has now been fixed) a design bug of the class. As 
> simple as that.

Quite the contrary
I showed if you remember that for regular expressions, dfas, graphs
the questions of when is one of these falsey is highly non-trivial.

In more general terms:
For complex data-types, the exact specific nature of which is ‘trivial’ may
be a highly non-trivial question.

About the python builtins — list, tuple, string, dict — for which these
questions seem straightforward and obvious:
In Haskell there is a type-class called Functor which informally corresponds
to collection type.
More formally for a type to be a functorial type it needs too have a
binary op and a constant.
For python lists it would be +, []
For sets ‘|’ (union ie ‘∪’ ) and ∅
etc
satisfying some mathematical properties which (being a bit fast and loose)
say that the operation, element need to be monoidal
ie the operation needs to be associative and element needs to be its identity

In THOSE TYPES that element can justifiably serve as a falsey (empty) type

However to extrapolate from here and believe that ALL TYPES can have a falsey 
value meaningfully, especially in some obvious fashion, is mathematically nonsense.

Mathematical gobbledygook of no interest? Ok here’s a 

tl;dr

1. Go back to this post’s OP. Is it not an authentic question?
2. Is something like it not a FAQ?



More information about the Python-list mailing list