Attribute error for NoneType

kimvais at gmail.com kimvais at gmail.com
Mon Sep 18 03:16:27 EDT 2017


Hi,

A common source of confusion for newbies is the `AttributeError: NoneType has no attribute ...`

Also, one of my pet peeves for violating EAFP is the common `if something is not None:` ...

Both of these could be "fixed" by having a new exception (that subclasses AttributeError) e.g. `IsNoneError` (for the lack of better name) that is raised whenever `None`'s attributes are accessed.

Of course, one can already write `try: .. except AttributError` - but that catches also whenever something else than `None` is being accessed.

Do you guys think that this might be PEP-worthy idea?

<< K



More information about the Python-list mailing list