def foo(x): return x.fld if hasattr(x, "fld") else 42