Skip to content

Latest commit

 

History

History
18 lines (12 loc) · 1.41 KB

README.md

File metadata and controls

18 lines (12 loc) · 1.41 KB

nopy

PyPi version Documentation Status PyPi license Code style: black

Python has a None object that is often used as a placeholder or a default value. This works nice, except that None has a very limited number of attributes, can not be called, and you can not subscript it. This means that if a function does something with None, you typically get an AttributeError or TypeError.

We introduce Nones little brother Nope. Nope is an object where all attributes (except a few) all return Nope, and you can subscript with any key to get Nope. Nope even arises when you call Nope with whatever parameters available. It is thus meant to make long useless chains of attributes, items, and method calls, like:

from nopy import Nope

Nope.foo.bar['qux'][1].bla(None)  # Nope

This is often not a good idea: exceptions should be silenced explicitly, not implicitly. But Nope is used as some sort of placeholder or a parameter, if the code where we use it will fetch attributes, make method calls, or subscript, and we don't want this to have any effect.