1

I need choose which parameter i use for function in function.

For example:

def some(key, gey, mey):
    return 0


def any(parameter_name, parameter_value):
    some(parameter_name=parameter_value)


any(mey, "May")

any(mey, "May") should equel some(mey="May")

1 Answer 1

1

You can use the **kwargs syntax. It will filter attribute by attribute_value.

def get_object_id(attribute: str, attribute_value):
    MyModel.objects.get(**{attribute: attribute_value})
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.