ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/ns_dev/Python/learning/Mark/mymod.py
Revision: 8
Committed: Sat May 5 04:21:19 2012 UTC (13 years, 10 months ago) by ninoborges
Content type: text/x-python
Original Path: Python/NinoCode/learning/Mark/mymod.py
File size: 539 byte(s)
Log Message:
Initial Import

File Contents

# User Rev Content
1 ninoborges 8
2    
3     import os
4    
5     def CountLines(fileObj):
6     fileObj.seek(0)
7     contents = fileObj.readlines()
8     return len(contents)
9    
10    
11     def CountChars(fileObj):
12     fileObj.seek(0)
13     contents = fileObj.read()
14     return len(contents)
15    
16     if __name__ == '__main__':
17     inputFile = open(r"C:\Documents and Settings\eaborges\Desktop\Working\readme.txt",'r')
18     numbLinesFound = CountLines(inputFile)
19     numbCharsFound = CountChars(inputFile)
20     print "This file contains %d lines and %d characters"% (numbLinesFound, numbCharsFound)