Are the critiques in "All the things I hate about Python" valid?

Chris Angelico rosuav at gmail.com
Sun Feb 18 21:59:09 EST 2018


On Mon, Feb 19, 2018 at 1:14 PM, bartc <bc at freeuk.com> wrote:
> On 19/02/2018 00:09, Steven D'Aprano wrote:
>
>> Sure, but only the most boring, uninteresting kinds of types can be so
>> named. The point is that "sufficiently fine-grained types" can be
>> arbitrarily complex.
>
>
> I don't think so.
>
>  If a human finds it hard to give it a meaningful
>>
>> name, no algorithm will do it either. Consider:
>>
>> "positive odd integers greater than 10 but less than 15003 divisible by
>> 17 except for 850, 867 and 1394; or primes that aren't Mersenne primes".
>
>
> Is that a type? Or a function? Or a set? Or a constraint?
>
> How would even a type for the odd numbers from 1 to 10 inclusive work?
> (That, a type consisting of one of the values in {1,3,5,7,9}.) Would they be
> ordered or unordered? Can I do arithmetic with them: will 3*3 work, but not
> 3*5?

The type is "positive odd number below ten" and could be written as
int(1..9|1%2). That is an orderable type; you can say that 3 < 7, for
instance. And yes, arithmetic would be defined just fine; there's no
requirement for the result of an operation to have the same type as
its inputs:

>>> 5 / 2 # two integers
2.5

I don't understand what your concern here is.

ChrisA



More information about the Python-list mailing list