[issue42497] New pathlib.Path attribute

2020-11-30 Thread Eryk Sun
Change by Eryk Sun : -- resolution: -> duplicate stage: -> resolved status: open -> closed superseder: -> Add to pathlib function to check permission similar to os.access ___ Python tracker

[issue42497] New pathlib.Path attribute

2020-11-29 Thread ThatXliner
ThatXliner added the comment: Ok, so I just made a patch implementing this using os.access. It adds the following methods to pathlib.Path - can_read= Returns True if the user can read the path - can_write = Returns True if the user can write on the path - can_execute = Returns True

[issue42497] New pathlib.Path attribute

2020-11-29 Thread ThatXliner
ThatXliner added the comment: Now I think of it, it would be weird to just add attributes testing for executable permissions. Why not add the attributes from os.access to pathlib.Path? - Path.can_execute = os.access(path, os.X_OK) - Path.can_read= os.access(path, R_OK) ...

[issue42497] New pathlib.Path attribute

2020-11-29 Thread ThatXliner
ThatXliner added the comment: Also, an App (at least on MacOS) is technically an executable (I've ran iMessage from the command line before). -- ___ Python tracker ___

[issue42497] New pathlib.Path attribute

2020-11-29 Thread ThatXliner
ThatXliner added the comment: Since pathlib.Path has module os synonyms, I think it would be reasonable to test with os.X_OK. Correct me if I'm wrong. I think most people would want to check if the current user running the script could execute something. -- type: -> enhancement

[issue42497] New pathlib.Path attribute

2020-11-29 Thread Steven D'Aprano
Steven D'Aprano added the comment: As a new feature, this could only go into 3.10, 3.9 is in feature freeze. The requirements are unclear, it could mean any of: - the file's *owner* has the execute bit set; - the file's mode has any execute bit set; - the *current user* has execute

[issue42497] New pathlib.Path attribute

2020-11-28 Thread ThatXliner
New submission from ThatXliner : Add an attribute to pathlib.Path testing if a file/directory/symlink is executable or the user has executable permissions. I've been trying to find a pythonic way for this (preferably in pathlib.Path) but all I found was trips to the shell and back. This