Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
PEP 722: Python dependencies for single-file scripts (github.com/python)
2 points by BiteCode_dev on July 22, 2023 | hide | past | favorite | 2 comments


> To be recognised as a “comment line”, the line must start with a # symbol. Leading and trailing whitespace on the comment line is ignored.

If a line is " # Requirements:" a comment line?

I can remove leading whitespace on a comment line, but since it does not start with a "#" symbol, it is not a comment line. In fact, according to this line, there's no such thing as a comment line with leading whitespace.

Or is "leading" meant to be the spaces between the "#" and the "Requirements:"?

On a broader topic, I certainly haven't followed this issue. I'm curious why an embedded string with a special name wasn't used, like:

  __pyproject_toml__ = """\
  [build-system]
  requires = ["requests", "rich ~= 58.0"]
  """
where only '[build-system.requires]' is supported. I think this could be extracted statically, through the AST, so no eval needed.

One of the links lead me to alternative proposals at https://github.com/jaraco/pip-run/issues/44 but none of them fit this form. (It's "Variant 1: single variable" with '__pyproject_toml__' as the variable name, "Option 2: Requirements.txt in comments" but in a string, and as TOML.)

The main objection seems to be 'Users may be tempted to dynamically construct the list (through runtime execution), but only static values are supported.' replacing 'list' with 'string'.

I have such a poor grasp one what "users" want that I can't judge.


In general there seems to be a hack that pops up again and again in programming languages, namely shoehorning structured data into comments.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: