Commit 773e5fa2 by Victor Shnayder

shorter impl of is_file

parent 03fd4f9b
...@@ -53,8 +53,4 @@ def is_file(file_to_test): ...@@ -53,8 +53,4 @@ def is_file(file_to_test):
''' '''
Duck typing to check if 'file_to_test' is a File object Duck typing to check if 'file_to_test' is a File object
''' '''
is_file = True return all(hasattr(file_to_test, method) for method in ['read', 'name'])
for method in ['read', 'name']:
if not hasattr(file_to_test, method):
is_file = False
return is_file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment