decompose this and recommend not using a try/except. check ``isinstance(foo, file)``