How to get the realpath of a symbolic link?

Emile van Sebille emile at
Sat Oct 31 17:26:44 CET 2009

On 10/31/2009 12:03 AM Peng Yu said...
> Suppose that I have the following directory and files. I want to get
> the canonical path of a file, a directory or a symbolic link.
> For example, for 'b' below, I want to get its canonical path as
> '/private/tmp/abspath/b'.

So, why isn't realpath working for you?  It looks like it is, and it 
works that way here:

 >>> os.path.realpath('/home/emile/vmlinuz')


More information about the Python-list mailing list