โ— LIVE
OpenAI releases GPT-5 APIIndia AI startup raises $120MBitcoin ETF hits record inflowsMeta Llama 4 benchmarks leakedOpenAI releases GPT-5 APIIndia AI startup raises $120MBitcoin ETF hits record inflowsMeta Llama 4 benchmarks leaked
๐Ÿ“… Sat, 21 Mar, 2026โœˆ๏ธ Telegram
AiFeed24

AI & Tech News

๐Ÿ”
โœˆ๏ธ Follow
๐Ÿ Home๐Ÿค–AI๐Ÿ’ปTech๐Ÿš€Startupsโ‚ฟCrypto๐Ÿ”’Security๐Ÿ‡ฎ๐Ÿ‡ณIndiaโ˜๏ธCloud๐Ÿ”ฅDeals
โœˆ๏ธ News Channel๐Ÿ›’ Deals Channel
Home/Cloud & DevOps/Automatically Revert Temporary Value Changes in a with Block
โ˜๏ธCloud & DevOps

Automatically Revert Temporary Value Changes in a with Block

The new rollback() API introduced in triggon v2.0.0 can automatically revert temporary changes to variables and attributes made in a with block. 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.

โšกQuick SummaryAI generating...
T

tsuruko

๐Ÿ“… Mar 21, 2026ยทโฑ 2 min readยทDev.to โ†—
โœˆ๏ธ Telegram๐• TweetWhatsApp
๐Ÿ“ก

Original Source

Dev.to

https://dev.to/tsuruko12/automatically-revert-temporary-value-changes-in-a-with-block-2dfb
Read Full โ†—

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 library, but rollback() can be used easily without registering labels, variables, or attributes in advance.

It also includes other unique features such as deferred execution and flexible early-return handling, so feel free to check it out if you're interested.

Tags:#cloud#dev.to

Found this useful? Share it!

โœˆ๏ธ Telegram๐• TweetWhatsApp

Read the Full Story

Continue reading on Dev.to

Visit Dev.to โ†—

Related Stories

โ˜๏ธ
โ˜๏ธCloud & DevOps

Majority Element

about 2 hours ago

โ˜๏ธ
โ˜๏ธCloud & DevOps

Building a SQL Tokenizer and Formatter From Scratch โ€” Supporting 6 Dialects

about 2 hours ago

โ˜๏ธ
โ˜๏ธCloud & DevOps

Markdown Knowledge Graph for Humans and Agents

about 2 hours ago

Moving Beyond Disk: How Redis Supercharges Your App Performance
โ˜๏ธCloud & DevOps

Moving Beyond Disk: How Redis Supercharges Your App Performance

about 2 hours ago

๐Ÿ“ก Source Details

Dev.to

๐Ÿ“… Mar 21, 2026

๐Ÿ• about 5 hours ago

โฑ 2 min read

๐Ÿ—‚ Cloud & DevOps

Read Original โ†—

Web Hosting

๐ŸŒ Hostinger โ€” 80% Off Hosting

Start your website for โ‚น69/mo. Free domain + SSL included.

Claim Deal โ†’

๐Ÿ“ฌ AiFeed24 Daily

Top 5 AI & tech stories every morning. Join 40,000+ readers.

โœฆ 40,218 subscribers ยท No spam, ever

Cloud Hosting

โ˜๏ธ Vultr โ€” $100 Free Credit

Deploy cloud servers in 25+ locations. From $2.50/mo. No contract.

Claim $100 Credit โ†’
AiFeed24

India's AI-powered tech news hub. Daily coverage of AI, startups, crypto and emerging technology.

โœˆ๏ธ๐Ÿ›’

Topics

Artificial IntelligenceStartups & VCCryptocurrencyCybersecurityCloud & DevOpsIndia Tech

Company

About AiFeed24Write For UsContact

Daily Digest

Top 5 AI stories every morning. 40,000+ readers.

No spam, ever.

ยฉ 2026 AiFeed24 Media.Affiliate Disclosure โ€” We earn commission on qualifying purchases at no extra cost to you.
PrivacyTermsCookies