Skip to main content

A silly little helper function, that is strangly helpful. All it does, is prompt a yes or question, then convert a boolean to the answer of yes or now. This library is meant to be used in debug strings, it is recommended to use in multi line f string meant to be passed to a log.debug. It mean to help make understanding the state just a little easier.

Project description


This silly seemingly useless function, makes debugging suprisingly easy.


Requres Python 3.8 or above, and can be installed with pip or poetry. To install with pip, simply run:

pip install yes-or-no

To install with poetry, run:

poetry add yes-or-no


When debugging code, it is often helpful to know whether a particular condition is True or False. However sometimes the True state is fail state, this allows to ask the question in the form: Are you sure this condition is False: yes if false no if True This function allows you to frame a test as a question with a yes or no answer, which can make it easier to understand the results.

For example, if you are testing whether a server is accessible, you can use this function to ask the question "Is the server up?" and get a clear answer based on the server's status code.

How I like to use it, is in multi line f strings, which I will pass to a log.debug. The fact that it's a mutli line f sting allows for documentation around what is happening in code.

#sever_return_200(ip_address) -> bool: True if status is 200 else False
            This can be a detailed debug, that explain what code is doing,
            and why these question might asked. So for example, a server is 
            needed to be accessable by the program. So you could write a test
            fot that and use it as your yes or no indicator. The reason I 
            made this is sometimes True is the valid and sometimes False, but asking
            question it's clear which state is valid and which is not
            {yes_or_no('Is the server up',server_return_200(ip_address))}


question (str): This the question you want answer when debuging.
example: "Is the server up"
answer (bool): This a boolean function that answers the question
example: server_return_200(ip_address)        


str: A string that ask and answers the question
example: Is the server up: yes if server returns 200 status else no        

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

yes_or_no-1.0.0.tar.gz (6.1 kB view hashes)

Uploaded Source

Built Distribution

yes_or_no-1.0.0-py3-none-any.whl (6.9 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page