[Answered ]-Can i set the default value of my function parameter as value from another function

1👍

You could do:

def get_report_obj(id):
    try:
        report_obj = report.objects.get(id)
        return report_obj
    except report.DoesNotExist:
        return False

and when you call the function get_report_obj you provide the parameter as the get_latest_id function like:

try:
    get_report_obj(get_latest_id())
except ....:
    ....

By directly providing id as a function when calling get_report_obj inside a try except, you guarantee that the parameter id exists which makes the if statements redundant.

👤r9119

Leave a comment