This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env python | |
"""Emulate Go's 'defer' statement. | |
The defer decorator adds the 'defer' function to the wrapped opject | |
that will push a callable and its arguments to a stack. The list of | |
saved calls is executed after the surrounding function returns. Defer | |
is commonly used to simplify functions that perform various clean-up | |
actions. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Imports Microsoft.VisualBasic | |
Public Class FormatFromDictionary | |
Private format As String | |
Private safe As Boolean | |
Private rex As System.Text.RegularExpressions.Regex | |
Sub New(format As String, Optional safe As Boolean = False) | |
Me.format = format | |
Me.safe = safe | |
Me.rex = New System.Text.RegularExpressions.Regex("\{([^,:}]+)([,:][^}]*)?\}") | |
End Sub |