Handle iterable and non-iterable seamlessly
- by Cheolho
Could you let me know how I can optimize the following code?
def f(y, list_or_elem):
if getattr(list_or_elem, '__iter__'):
y = max(y, *list_or_elem)
else:
y = max(y, list_or_elem)