Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

stat() got an unexpected keyword argument 'follow_symlinks'

Web search found links to bugs, I don’t write complicated code on Python, just want to confirm I understand syntax:

https://docs.python.org/3/library/pathlib.html

Path.stat(*, follow_symlinks=True)

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

But when I write Path(filepath).stat(follow_symlinks=False) I’m getting "stat() got an unexpected keyword argument ‘follow_symlinks’" error. lstat() in place of stat(follow_symlinks=False) does job done.

Python 3.8.5. TIA

>Solution :

You’re reading it correctly. You just missed the footnote. From the page you linked

Changed in version 3.10: The follow_symlinks parameter was added.

So if you want to use that keyword argument, you need Python 3.10 or newer. Otherwise, as you’ve already figured out, just use lstat.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading