Use python to reproduce bash command 'ls -a' output

Viewed 17305

I am new to python and am working on writing bash ls command in python, I am stuck on ls -a option which (according to the manpage):

Include directory entries whose names begin with a dot (`.')

I am aware of os.listdir() but it does not list special entries '.' and '..'

From the docs: os.listdir(path):

Return a list containing the names of the entries in the directory given by path. The list is in arbitrary order. It does not include the special entries '.' and '..' even if they are present in the directory.

I need help in listing these special entries through python, I would appreciate if someone can help me out here a little.

Thanks all for your patience.

1 Answers
Related