# With-Assignment statement

**URL:** <https://discuss.python.org/t/with-assignment-statement/57887>\
**Category:** Ideas\
**Created:** [July 11, 2024, 8:19am UTC](https://discuss.python.org/t/with-assignment-statement/57887 "2024-07-11T08:19:19Z")\
**Posts on this page:** 1\
**Showing post:** 7

<div class="post-metadata">

**Author:** ![JamesParrott](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/jamesparrott/32/10534_2.png) [@JamesParrott](https://discuss.python.org/u/JamesParrott)\
**Post date:** [July 11, 2024, 12:49pm UTC](https://discuss.python.org/t/with-assignment-statement/57887/7 "2024-07-11T12:49:02Z")

</div>

OK, I’m not sure what the point of using a string literal in a `with` statement is, but you’ve really thought about this.

Regarding “not cleaning up x afterwards”. Yes. Currently there’s no expectation that an indented `with` block creates a new scope. Allowances were made for list comprehensions, but in general introducing a new scope, where previously there was none, requires extraordinary supporting evidence, I feel. `with` statements are understood to be syntactic sugar for ` __enter__ ` and ` __exit__ ` methods in a `try` `finally` block. A very strong case is needed to change the way Python users can currently reason about their code.

Have you looked at rolling your own wrapper, that calls `del` on the new name in the `with` afterwards?

---

_[View the full topic](https://discuss.python.org/t/with-assignment-statement/57887)._
