Skip to content

Latest commit

 

History

History
26 lines (21 loc) · 470 Bytes

README.md

File metadata and controls

26 lines (21 loc) · 470 Bytes

defer.py

golang defer equivalent in python

Install

pip install git+https://github.com/loynoir/defer.py

Usage

from Defer import Defer

with Defer() as defer:
    print("enter the room")
    defer(lambda: print("leave the room"))

    print("prepare printer")
    defer(lambda: print("close printer"))

    print("start printing")
    defer(lambda: print("end printing"))

    print(3)
    print(4)
    print(5)
    print("LONG LONG TASKS")