python: run the second condition after the first one becomes false
--------------------------------------------------
Rise to the top 3% as a developer or hire one of them at Toptal: https://topt.al/25cXVn
--------------------------------------------------
Music by Eric Matyas
https://www.soundimage.org
Track title: Realization
--
Chapters
00:00 Python: Run The Second Condition After The First One Becomes False
00:43 Accepted Answer Score 3
01:10 Thank you
--
Full question
https://stackoverflow.com/questions/6946...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#python #process #conditionalstatements
#avk47
    Rise to the top 3% as a developer or hire one of them at Toptal: https://topt.al/25cXVn
--------------------------------------------------
Music by Eric Matyas
https://www.soundimage.org
Track title: Realization
--
Chapters
00:00 Python: Run The Second Condition After The First One Becomes False
00:43 Accepted Answer Score 3
01:10 Thank you
--
Full question
https://stackoverflow.com/questions/6946...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#python #process #conditionalstatements
#avk47
ACCEPTED ANSWER
Score 3
We can leverage decorators1 here to enforce the invariant.
def fill_if_empty(func):
    def wrapper(*args, **kwargs):
        if YOUR_CONDITION_TO_CHECK_FOR_EMPTY_DIR:
            """
            fill empty directory here.
            """
            process_user_input()
        func(*args, **kwargs)
    return wrapper
@fill_if_empty
def do_process_on_the_full_directory():
    """
    Run some process on directory
    """
    pass
do_process_on_full_directory() 
1. Checkout this post to know more about decorators: How to make function decorators and chain them together?