I'm a lurker on this list and wanted to submit my own idea. It's a feature
I've been wanting in Python for a while, and I have a simple implementation
for it for personal use at the moment. Wanted to get feedback before I move
forward.
Essentially, I want to be able to perform a simple default get on a list if
an index does not exist, similar to a dictionary. For example:
*my_dict = {"test1": "value1"}*
*my_dict.get("test2", None)*
results in a "None" value, since the key doesn't exist.
…
[View More]Similarly with a list:
*my_list = [1, 2, 3]*
*my_list.get(10, 0)*
says that since index 10 does not exist, I expect a 0 to be returned.
Currently, you have to check the length of the list of use a try/except,
which takes more lines than I'd like to use.
I'm welcoming feedback on this feature, or if it's already been discussed
then I'm expecting to be shut down.
Thank you for your time!
[View Less]
Hello,
I have a small suggestion to make about the generation of the
`__pycache__` directory. Would it be possible to also generate a
`CACHEDIR.TAG` file in this directory when running Python on Linux? The
file is (informally?) specified at <https://bford.info/cachedir/>. This
would allow `__pycache__` to be automatically excluded by various Linux
tools such as `tar` (using the `--exclude-caches-all` flag).
Cheers,
Leon