Recently you need to count the total number of lines of code in your project, write a Python applet, and have to say how concise Python is, if you write it in Java at least twice times the code.
[Code]
Import OS
Path= "/users/rony/workspace/ecommerce/ecommerce/hot-deploy/"
Global TotalCount
TotalCount =0
def cfile (path):
Allfiles = Os.listdir (path)
For file in Allfiles:
Child = Os.path.join (path,file)
If Os.path.isdir (child):
CFile (Child)
Else
filename,fileext= Os.path.splitext (Child)
Print (Fileext)
#file type need to calculate
If fileext in ['. Java ', '. jsp ', '. html ', '. htm ', '. xml ', '. sql ', '. js ', '. FTL ', '. css ', '. Groovy ']:
countf = Len (open (Child, ' RU '). ReadLines ())
Global TotalCount
totalcount=totalcount+countf;
Print (child)
Print (countf)
CFile (PATH)
Print (TotalCount)
The analysis on the code here, the example is relatively simple.