osdir.com


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Tutor] beginning to code


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.

ChrisA