Python: Can you write an efficient code to count the number of capital letters in a file?

 Suppose file contain text "Hello Capital World!" 

with open('/mypath/mycapitalfile.txt') as countletter:
    count = 0
    file_text =
    for character in file_text:
        if character.isupper():
            count += 1

print("Total Capital Letters in file:", count)  

This will print, Total Capital Letters in file: 3

Another efficient way of doing this:

with open('/Users/tarungoswami/Python Practice/mycapitalfile.txt') as countletter:
    count = sum(1 for line in countletter for character in line if character.isupper())
print("Total Capital Letters in file:",count)