easy question on parsing python: "is not None"
Ben Finney
ben+python at benfinney.id.au
Sat Aug 7 19:16:26 EDT 2010
Peter Pearson <ppearson at nowhere.invalid> writes:
> Hey, that's a cute example, but . . . what a trap! Is it possible to
> document the use-the-object-not-the-string requirement loudly enough
> that people won't get caught?
Don't use strings for such values. The data isn't going to be used, so
there's no sense using a semantically rich data type like a string.
Instead, use an ‘object’ instance; then, the only way to get a binding
that will compare equal is to use the very object itself.
FORWARD = object()
BACKWARD = object()
--
\ “Never do anything against conscience even if the state demands |
`\ it.” —Albert Einstein |
_o__) |
Ben Finney
More information about the Python-list
mailing list