python / python/cpython

with statement star target

オープン
#135,617 コメント 3 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

docs topic-parser
主要言語
Python
スター
77.2k
フォーク
35.9k
PR マージ指標
PR 指標を取得中

説明

Documentation

https://docs.python.org/3/reference/simple_stmts.html#grammar-token-python-grammar-target

According to the docs, the grammar for the with statement allows:

with_stmt                          ::= "with" with_stmt_contents
with_stmt_contents           ::= with_item
with_item                          ::= expression "as" target
target                                ::= identifier  | "*" target

from my understanding that would allow a python syntax like this:


class Test:
    def __enter__(self):
        return (1, 2)

    def __exit__(self, exc_type, exc_value, traceback):
        pass


with Test() as *mambo:
    print(mambo, type(mambo))

But for me with python version 3.12.8

I get a syntax error:

  File "/home/gringo/accessia/main/controller_start/test.py", line 9
    with Test() as *mambo:
                   ^^^^^^
SyntaxError: starred assignment target must be in a list or tuple

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

with-statement の文法に関する、参照されている Python language-reference のセクションから始め、Python 3.12.8 で例を再現してください。文書化された対象文法と報告された SyntaxError を比較してください。ドキュメントと観測された動作の整合が取れ、関連する文言または文法が明確化されれば完了です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
python
領域
documentation
issue の種類
ドキュメント
難易度
3/5
見積もり時間
1〜2日
活発さ
停滞
明瞭さ
説明が足りない
初心者へのやさしさ
35/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。