Skip to content

Conversation

@legendof-selda
Copy link

@legendof-selda legendof-selda commented Sep 2, 2023

As described in #12, Sentinels truthyness depends on the context of the sentinel.
This allows us to set what the sentinel can mean, and by default sentinels are ambiguous and forces the user to give it a meaning.

Example

from sentinels import Sentinel

EOF = Sentinel('EOF')

# This will return a `ValueError` since EOF doesn't have a Boolean representation
# bool(EOF)
# However, we can compare a value with EOF and that does have a Boolean representation
line= read_line(file)
print(line is EOF)

Undefined = Sentinel('undefined', truthy=False)

bool(Undefined)
# >> False

Success = Sentinel('success', truthy=True)

bool(Success )
# >> True

@legendof-selda
Copy link
Author

I haven't updated the documents yet. If this get's approved, I will update it then

@legendof-selda
Copy link
Author

any update on this @taleinat ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant