Permanent objects?
Cliff Wells
clifford.wells at attbi.com
Thu Dec 26 13:48:23 EST 2002
On Thu, 2002-12-26 at 01:16, Erik Max Francis wrote:
> Cliff Wells wrote:
>
> > But then isn't this sort of like the case where a function tests the
> > type of object being passed to it (i.e. type(s) == type(""))? There
> > have been arguments on this list in the past that it's bad to
> > explicitly
> > test for a particular type, so wouldn't this fall in the same
> > category?
> > That is, if an object mimics a particular type, and can be used in
> > place
> > of that type, why should a function exclude it if it isn't that type?
>
> That's definitely true (most of the time, anyway) for the case of
> explicit type tests. In a dynamic language like Python, it really
> doesn't matter if the object has a certain type, it just matters that it
> has the right interface.
>
> Tests against None are genuinely different, however. None is usually
> used to indicate the lack of another meaningful object. In other words,
> None is a _unique_ object that says, "There's no object here." In other
> words, None is used as a sentinel object to represent something special,
> distinct from all other objects. There's exactly one None, and it's
> different from everything else.
Thanks. That clears it up.
--
Cliff Wells <clifford.wells at attbi.com>
More information about the Python-list
mailing list