<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:

def detect_current_filename():
    ''' Attempt to return the filename of the currently running Python process

    Returns None if the filename cannot be detected.
    '''
    import inspect

    filename = None
    frame = inspect.currentframe()
    try:
        while frame.f_back and frame.f_globals.get('name') != '__main__':
            frame = frame.f_back

        filename = frame.f_globals.get('__file__')
    finally:
        del frame

    return filename