Unit testing errors (testing the platform module)

J. Cliff Dyer jcd at sdf.lonestar.org
Wed Apr 14 11:19:47 EDT 2010

On Wed, 2010-04-14 at 15:51 +0100, john maclean wrote:
> self.assertEqual(platform.__builtins__.__class__, dict,
> "platform.__class__ supposed to be dict")
> self.assertEqual(platform.__name__, 'platform' ) 

The preferred spelling for:


would be


It's shorter and easier to read, but essentially says the same thing.

You can also use it on integer literals, which you can't do with your

    >>> type(1)
    <type 'int'>
    >>> 1.__class__
    SyntaxError: invalid syntax

Admittedly, this is a trivial benefit.  If you're using a literal, you
already know what type you're dealing with.


More information about the Python-list mailing list