FlareStart
HomeNewsHow ToSources
FlareStart

Where developers start their day. All the tech news & tutorials that matter, in one place.

Quick Links

  • Home
  • News
  • Tutorials
  • Sources
  • Privacy Policy

Connect

© 2026 FlareStart. All rights reserved.

Back to articles
Automatically Revert Temporary Value Changes in a with Block
NewsProgramming Languages

Automatically Revert Temporary Value Changes in a with Block

via Dev.to Pythontsuruko3h ago

The new rollback() API introduced in triggon v2.0.0 can automatically revert temporary changes to variables and attributes made in a with block. It also supports local variables, so it's only available on CPython 3.13+. Code Example Here's a simple example. In this example, the variable x is assigned 99 inside the block, but once the block exits, it's restored to its original value, 1 . from triggon import Triggon x = 1 with Triggon . rollback (): x = 99 print ( x ) # 99 print ( x ) # 1 You can also pass the names of variables or attributes to rollback() , so only the specified targets will be restored. class A : a = 10 x = 0 # x isn't included in the rollback target with Triggon . rollback ( " A.a " ): x = 99 A . a = - 10 print ( x ) # 99 print ( A . a ) # -10 print ( x ) # 99 print ( A . a ) # 10 Variables defined inside the block aren't restored. triggon recently had a major update with 8 new APIs. You can check the details in the release notes . triggon is basically a label-based l

Continue reading on Dev.to Python

Opens in a new tab

Read Full Article
2 views

Related Articles

News

Typechecking mCRL2

Lobsters • 3h ago

News

Agentic pre-commit hook with Opencode Go SDK

Lobsters • 4h ago

"Arcangel Legrand - Brotherswagg: Official Release of Everybody (Unleashed) - 2026/03/21 |…
News

"Arcangel Legrand - Brotherswagg: Official Release of Everybody (Unleashed) - 2026/03/21 |…

Medium Programming • 4h ago

Why Your ‘ALTER TABLE’ Would Crash Production
News

Why Your ‘ALTER TABLE’ Would Crash Production

Medium Programming • 4h ago

Where, How Much, and What’s Next: A Philosophical View of Computing
News

Where, How Much, and What’s Next: A Philosophical View of Computing

Medium Programming • 4h ago

Discover More Articles