[issue42497] New pathlib.Path attribute
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 issue proposes adding an attribute (which I haven't figured the name most would like but it would be somewhere near .can_execute or .is_exe) -- components: Library (Lib) messages: 382034 nosy: ThatXliner priority: normal severity: normal status: open title: New pathlib.Path attribute versions: Python 3.10, Python 3.9 ___ Python tracker <https://bugs.python.org/issue42497> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue42497] New pathlib.Path attribute
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 ___ Python tracker <https://bugs.python.org/issue42497> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue42497] New pathlib.Path attribute
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 <https://bugs.python.org/issue42497> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue42497] New pathlib.Path attribute
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) ... -- ___ Python tracker <https://bugs.python.org/issue42497> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue42497] New pathlib.Path attribute
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 if the user can execute the path These are implemented via - return os.access(str(self), os.R_OK) - return os.access(str(self), os.W_OK) - return os.access(str(self), os.X_OK) respectively. -- keywords: +patch Added file: https://bugs.python.org/file49637/implement.patch ___ Python tracker <https://bugs.python.org/issue42497> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue42017] Add new type in typing
New submission from ThatXliner : Because there is a typing.AnyStr (which is equal to AnyStr = TypeVar("AnyStr", str, bytes)), I think there should be a AnyNum which is equivalent to from decimal import Decimal from fractions import Fraction AnyNum = TypeVar("AnyNum", int, float, complex, Decimal, Fraction) -- components: Library (Lib) messages: 378505 nosy: ThatXliner priority: normal severity: normal status: open title: Add new type in typing type: enhancement versions: Python 3.10 ___ Python tracker <https://bugs.python.org/issue42017> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue42017] Add new type in typing
Change by ThatXliner : -- versions: +Python 3.10 ___ Python tracker <https://bugs.python.org/issue42017> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue42017] Add new type in typing
Change by ThatXliner : -- versions: +Python 3.9 -Python 3.10 ___ Python tracker <https://bugs.python.org/issue42017> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue42023] Argparse: Add a "display" arg
New submission from ThatXliner : In argparse, I've always wanted a way to make colored help text like those of poetry and pipenv. But argparse's show help isn't well documented (Therefore, I can't find a way to completely modify the help text), and the metavar arg isn't really helpful. I want to do something like this: >>> import argparse >>> parser = argparse.ArgumentParser() >>> parser.add_argument("foo", help="To foo a bar", display="FOO") >>> parser.print_help() usage: main.py [-h] foo positional arguments: FOO To foo a bar optional arguments: -h, --help show this help message and exit >>> That way, I can colorize the help output. -- components: Library (Lib) messages: 378526 nosy: ThatXliner priority: normal severity: normal status: open title: Argparse: Add a "display" arg type: enhancement versions: Python 3.10, Python 3.9 ___ Python tracker <https://bugs.python.org/issue42023> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue42023] Argparse: Add a "display" arg
ThatXliner added the comment: >However, I can imagine adding a variable that gives the user full control over >the action-invocation. In: argparse.HelpFormatter._format_action_invocation method. That's what I'm trying to change. If there was a public API/method for manipulating the left side of the help menu. (This part) (Manipulatable via help=) -- ___ Python tracker <https://bugs.python.org/issue42023> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue42023] Argparse: Add a "display" arg
ThatXliner added the comment: Should I rename this to "Argparse: finer control on help txt" -- ___ Python tracker <https://bugs.python.org/issue42023> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue42023] Argparse: Add a "display" arg
ThatXliner added the comment: > So if you can get by with just customizing _format_action_invocation, there's > no need for further action here. Then maybe we could just make a new function that takes 2 arguments: Name of another action class (or the action class itself), and a tuple of the arg names to be displayed. It returns a new action class that contains the help text properties of the given action class with customized displayed arg names. Maybe like parser.add_argument("-f", "--foo", action=argparse.CustomArgName(action="store_true", name=("-F!!", "--FOO!"), help="TO foo a bar")) -- ___ Python tracker <https://bugs.python.org/issue42023> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue42023] Argparse: Add a "display" arg
ThatXliner added the comment: Editing the description, etc. seems like a good way to do this. But it seems "hacky". The other answer on StackOverflow implements a custom class which does nice things, but not what I want. -- ___ Python tracker <https://bugs.python.org/issue42023> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue42023] Argparse: Add a "display" arg
ThatXliner added the comment: In the end, I think python's argparse needs more built-in help formatters... Should I close this? -- ___ Python tracker <https://bugs.python.org/issue42023> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue42468] subprocess.CompletedProcess: Add boolean value
New submission from ThatXliner : I propose making subprocess.CompletedProcess a truthy value if the returncode is 0. False, otherwise. -- components: Library (Lib) messages: 381871 nosy: ThatXliner priority: normal severity: normal status: open title: subprocess.CompletedProcess: Add boolean value versions: Python 3.10, Python 3.9 ___ Python tracker <https://bugs.python.org/issue42468> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue42468] subprocess.CompletedProcess: Add boolean value
Change by ThatXliner : -- type: -> enhancement ___ Python tracker <https://bugs.python.org/issue42468> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com