You get an error because you accept the self argument in each of these functions. They are static, you do not need it.
However, the "pythonic" way to do this is not to have a class full of static methods, but simply make them free functions in the module.
#fileutility.py: def get_file_size(fullName): fileSize = os.path.getsize(fullName) return fileSize def get_file_path(fullName): filePath = os.path.abspath(fullName) return filePath
Now in your other python files (assuming fileutility.py is in the same directory or on PYTHONPATH )
import fileutility fileutility.get_file_size("myfile.txt") fileutility.get_file_path("that.txt")
It doesn't mention static methods specifically, but if you come from a different PEP 8 language, the python style guide is a good read and introduction as python programmers think.
Collin 04 Oct '12 at 20:35 2012-10-04 20:35
source share