Skip to content

Commit

Permalink
Add snippet for Python context manager (#1743)
Browse files Browse the repository at this point in the history
## Why?
Context managers are fairly frequently used in Python; they're also
something of a Python-specfic construct.
For example:
```
with open(filepath) as f:
    file_lines = f.readlines()
```

## What?
Add context manager statement, used with `snip with` and `with wrap`.
`snip context` is a possible alternative name.
  • Loading branch information
afallou authored Feb 9, 2025
1 parent ee99869 commit 6d15eb3
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions core/snippets/snippets/withStatement.snippet
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: withStatement
phrase: with
insertionScope: statement

$0.wrapperPhrase: with
$0.wrapperScope: statement
---

language: python
-
with $1:
$0
---

0 comments on commit 6d15eb3

Please sign in to comment.