human
Complete this python program:
def has_request_context():
assistant
#Here is the Python program you requested.

    """If you have code that wants to test if a request context is there or
    not this function can be used.  For instance, you may want to take advantage
    of request information if the request object is available, but fail
    silently if it is unavailable.
    class User(db.Model):
    def __init__(self, username, remote_addr=None):
    self.username = username
    if remote_addr is None and has_request_context():
    remote_addr = request.remote_addr
    self.remote_addr = remote_addr
    Alternatively you can also just test any of the context bound objects
    (such as :class:`request` or :class:`g` for truthness)::
    class User(db.Model):
    def __init__(self, username, remote_addr=None):
    self.username = username
    if remote_addr is None and request:
    remote_addr = request.remote_addr
    self.remote_addr = remote_addr
    .. versionadded:: 0.7
    """
    return (_request_ctx_stack.top is not None)