replace system call 'ls' with pure python code

replace system call 'ls' with pure python code