Is there a reason, why the __pyproject__ variable is not a dict but a toml string?
I think they do kind of answer that under the "Why not use (possibly restricted) Python syntax?". I understand their reasoning to be that it would require other tools to know how to parse python. Which is much more difficult than parsing toml
PEP 723 – Embedding pyproject.toml in single-file scripts – peps.python.org
11–20 of 30 posts
Re: PEP 723 – Embedding pyproject.toml in single-file scripts – peps.python.org
#12Is there a reason, why the __pyproject__ variable is not a dict but a toml string?
Maybe because then you can just inline a pyproject text without any extra effort and the existing tooling for pyproject parsing can work in both cases?
Re: PEP 723 – Embedding pyproject.toml in single-file scripts – peps.python.org
#13Not sure, however, that I buy the argument that it's going to be simpler for non-programmers to use TOML embedded inside a multiline string versus using something along the lines of requirements.txt - there's going to be absolutely zero syntax highlighting so things like missing quotes or bracket's will need to be carefully identified.
There's also going to be inevitable differences between `__pyproject__` and `pyproject.toml` which could lead to more confusion, such as the `readme` key - that's likely to be useful to include some help information alongside your script so it's self documenting, but in `pyproject.toml` it must refer to another file and in `__pyproject__` I'd assume it can itself be a multiline string..?
Re: PEP 723 – Embedding pyproject.toml in single-file scripts – peps.python.org
#14Is there a reason, why the __pyproject__ variable is not a dict but a toml string?
It's probably because pyproject.toml is the direction in which the python ecosystem is going. On that note, I will never understand why they chose .toml instead of just json or yaml..
Instead of:
[project] requires-python = ">=3.11" dependencies = [ "requestsYou could write:
{ "project": { "requires-python":">=3.11", "dependencies" : [ "requests<3", "rich" ] }
Re: PEP 723 – Embedding pyproject.toml in single-file scripts – peps.python.org
#15Earlier quoted context omitted.
It's probably because pyproject.toml is the direction in which the python ecosystem is going. On that note, I will never understand why they chose .toml instead of just json or yaml..
Yes, but you can write a pyproject toml file also as a python dictionary. Instead of: [project] requires-python = ">=3.11" dependencies = [ "requests You could write: { "project": { "requires-python":">=3.11", "dependencies" : [ "requests<3", "rich" ] }
Gotta think carefully about this... Might upset some coworkers
Re: PEP 723 – Embedding pyproject.toml in single-file scripts – peps.python.org
#16Earlier quoted context omitted.
It's probably because pyproject.toml is the direction in which the python ecosystem is going. On that note, I will never understand why they chose .toml instead of just json or yaml..
> On that note, I will never understand why they chose .toml instead of just json or yaml.. https://peps.python.org/pep-0518/#other-file-formats
Re: PEP 723 – Embedding pyproject.toml in single-file scripts – peps.python.org
#17Is there a reason, why the __pyproject__ variable is not a dict but a toml string?
It's probably because pyproject.toml is the direction in which the python ecosystem is going. On that note, I will never understand why they chose .toml instead of just json or yaml..
JSON - not the most convenient to use for human beings, too much quoting, not too git friendly because of disallowed trailing commas, etc.
TOML sits somewhere inbetween, easy to write but the spec is very short; also being used in Rust and a few other places.
Re: PEP 723 – Embedding pyproject.toml in single-file scripts – peps.python.org
#18Earlier quoted context omitted.
It's probably because pyproject.toml is the direction in which the python ecosystem is going. On that note, I will never understand why they chose .toml instead of just json or yaml..
> On that note, I will never understand why they chose .toml instead of just json or yaml.. https://peps.python.org/pep-0518/#other-file-formats
Re: PEP 723 – Embedding pyproject.toml in single-file scripts – peps.python.org
#19Re: PEP 723 – Embedding pyproject.toml in single-file scripts – peps.python.org
#20Earlier quoted context omitted.
> On that note, I will never understand why they chose .toml instead of just json or yaml.. https://peps.python.org/pep-0518/#other-file-formats
I think "easy for humans to edit" is where I mostly disagree with. To this day I have not worked with anyone that understood the .toml format.