object types, mutable or not?

Chris Angelico rosuav at gmail.com
Wed May 16 13:33:54 EDT 2018


On Thu, May 17, 2018 at 1:03 AM, Ned Batchelder <ned at nedbatchelder.com> wrote:
> On 5/16/18 10:06 AM, Steven D'Aprano wrote:
>>
>> On Wed, 16 May 2018 09:23:02 -0400, Ned Batchelder wrote:
>>
>>> I've also experimented with different ways to better say "everything is
>>> an object".  One possibility is, "any right-hand side of an assignment
>>> is an object," though that is a bit tortured.
>>
>> What if there's no assignment?
>>
>>> Now I'm thinking of trying, "Any piece of data is an object."
>>
>> Is None data? How about True and False?
>>
>> Surely object() isn't data... and if it is, what about len?
>>
> This is what I meant by the complication when you get to a deeper discussion
> of all the possible kinds of Python values. I think even beginners would
> consider True and False as data.  The others take more explanation.
>

None takes only a little more explanation. It's data that says you
have no data. It's like asking "is zero a number?" - yes, there's a
mental leap to be made, but since it is so _exactly_ like zero's
status, it's not too hard to explain. (Nothing like as bad as
explaining SQL's NULL, which sometimes is a value, sometimes is a
placeholder meaning "there is no value here", sometimes is a
non-value, and sometimes just defies categorization.) Explaining that
*len* is data requires the concept of "functions are things, too",
which definitely takes some grokking.

ChrisA



More information about the Python-list mailing list