Python: format string with custom delimiters [duplicate]

I don’t think it is possible to use alternative delimiters. You need to use double-curly braces {{ }} for curly braces that you don’t want to be replaced by format(): inp = “”” DATABASE = {{ ‘name’: ‘{DB_NAME}’ }}””” dictionary = {‘DB_NAME’: ‘abc’} output = inp.format(**dictionary) print(output) Output DATABASE = { ‘name’: ‘abc’ }

Using C# 6 features with CodeDomProvider (Roslyn)

Update: March 2018 Word of caution, NuGet version 1.0.6 … 1.0.8 will not copy the /roslyn folder to the build output directory on non-web projects. Best stick with 1.0.5 https://github.com/aspnet/RoslynCodeDomProvider/issues/38 Run-time compilation using C#6 features requires a new compiler, as @thomas-levesque mentioned. This compiler can be installed by using the nuget package Microsoft.CodeDom.Providers.DotNetCompilerPlatform. For desktop … Read more

How do I convert a string into an f-string?

f-strings are code. Not just in the safe, “of course a string literal is code” way, but in the dangerous, arbitrary-code-execution way. This is a valid f-string: f”{__import__(‘os’).system(‘install ransomware or something’)}” and it will execute arbitrary shell commands when evaluated. You’re asking how to take a string loaded from a text file and evaluate it … Read more