Skip to content

Dynamic function call callback possibility? #648

Answered by bbence84
bbence84 asked this question in Q&A
Discussion options

You must be logged in to vote

Ok, lambda functions were working after all. :) Here is a little snippet in case someone tries to do something like this:

function_map={
        "get_books_of_series": lambda **data : func_call_proxy('get_books_of_series', **data),
        "get_book_first_published": lambda **data : func_call_proxy('get_book_first_published', **data),
    }

and

def func_call_proxy(function_name, **data):
    if function_name == 'get_books_of_series':
        return get_books_of_series(**data)
    if function_name == 'get_book_first_published':
        return get_book_first_published(**data)
    
def get_books_of_series(book_series_name):
    return ['Book1', 'Book2']

def get_book_first_published(book_ti…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by bbence84
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant