https://bugs.kde.org/show_bug.cgi?id=399533

            Bug ID: 399533
           Summary: No support for deconstructing tuple in 'with'
                    statement
           Product: kdev-python
           Version: 5.2.4
          Platform: Debian testing
                OS: Linux
            Status: REPORTED
          Severity: normal
          Priority: NOR
         Component: Language support
          Assignee: m...@svenbrauch.de
          Reporter: nicolas.alva...@gmail.com
  Target Milestone: ---

PEP 343 introduces the 'with' statement, and says this about the 'as' clause:

"with EXPR as VAR:

Here, 'with' and 'as' are new keywords; EXPR is an arbitrary expression (but
not an expression-list) and VAR is a single assignment target. It can not be a
comma-separated sequence of variables, but it can be a parenthesized
comma-separated sequence of variables."


This means the context manager's __enter__ method can return a sequence with
multiple elements, and you can deconstruct the sequence by putting a
"parenthesized comma-separated sequence of variables" in the 'as' clause:

class Mgr:
    def __enter__(self):
        return ('two', 'elements')
    def __exit__(self, *args):
        pass

with Mgr() as (foo, bar):
    print(foo)
    print(bar)


However, kdev-python doesn't support this. 'foo' and 'bar' will both appear as
undefined variables, underlined as errors.

-- 
You are receiving this mail because:
You are watching all bug changes.

Reply via email to