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

Attribute error for NoneType


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