[Tutor] beginning to code

Steve D'Aprano steve+python at pearwood.info
Tue Sep 19 20:44:07 EDT 2017


On Wed, 20 Sep 2017 03:22 am, Chris Angelico wrote:

> On Wed, Sep 20, 2017 at 2:20 AM, Steve D'Aprano
> <steve+python at pearwood.info> wrote:
>> I can only think of four operations which are plausibly universal:
>>
>> Identity: compare two operands for identity. In this case, the type of the
>> object is irrelevant.
>>
>> Kind: interrogate an object to find out what kind of thing it is (what class
>> or type it is). In Python we have type(obj) and isinstance(x, Type), plus a
>> slightly more specialised version issubclass.
>>
>> Convert to a string or human-readable representation.
>>
>> And test whether an object is truthy or falsey.
> 
> Equality checks are also close to universal. If you ask if this list
> is equal to that timestamp, you don't get an exception, you get False.


Ah yes! Good one, and an obvious one. Asking whether two things are
equal/unequal should be universal to.



-- 
Steve
“Cheer up,” they said, “things could be worse.” So I cheered up, and sure
enough, things got worse.




More information about the Python-list mailing list