I have a function that checks if the size of a file, and a known historic size are equal:
def SizeEqual(filePath: str, size: int) -> bool:
return os.path.getsize(filePath) == size
If I pass in a variable of type int that has a value equal to that of the file size, this function will return True, but if I pass in a variable of the value represented as a str, it will return False.
Example:
os.path.getsize(someFile) # Equal to 5803896
SizeEqual(someFile, 5803896) # Returns True
strVar = '5803896'
SizeEqual(someFile, strVar) # Returns False
I had thought that because I had specified the type in the function parameter, that Python would either prevent the str type from being passed in, or implicitly convert it to an int.
What am I missing?
False. E.g."123" == 123isFalse. - arshoint? - Progeny42