len(var) is [CONSTANT] equal to len(var) == [CONSTANT]?

Fredrik Lundh fredrik at pythonware.com
Thu Nov 23 08:28:45 EST 2006


Tor Erik Soenvisen wrote:

> I've seen code like this:
>
> if type([]) is list:
>    print 'Is list'
>
> which seem to work. And also I've seen "var is None", as you mention.

None is guaranteed to be a singleton:

    http://effbot.org/pyref/type-none.htm

Why "is" works for type objects should be pretty obvious, of course.

</F> 






More information about the Python-list mailing list