Possible Duplicate:
How to get line count cheaply in Python?
In my work i need to open a file and count no. of lines in that, i tried with this
Last_Line = len(open(File_Name).readlines())
It was working fine. Now i have a problem, actual no. of lines in the file is 453, but if i print Last_Line
it is showing only 339. If i try
print linecache.getline(File_Name, 350)
it is displaying the contents of line no. 350.
I tried opening the file in all modes. Whether its problem with file or with my logic? Please help.
thank you