"write") returns true) and if people forget to use it (perhaps becausehasattr() smells bad. It also has namespace issues (hasattr(transport,
the transport they normally use always has a certain attribute) their
code is brittle. Defining a new API with a string key signals clearly
that the value may or may not exist, and reminds people to test the
result for None. (Of course they can forget that too. But it still
feels different to me.)