Home > other >  stat() got an unexpected keyword argument 'follow_symlinks'
stat() got an unexpected keyword argument 'follow_symlinks'

Time:11-30

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)

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

CodePudding user response:

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.

  • Related