for decodingwe can write function that accepts dictionary and checks the existence of the is_contact variable to decide whether to convert it to contactdef decode_contact(dic)if dic get('is_contact')return contact(dic['first']dic['last']elsereturn dic we can pass this function to the load or loads function using the object_hook keyword argumentdata ('{"is_contact"true"last""smith",'"full""john smith""first""john"}' json loads(dataobject_hook=decode_contactc full_name 'john smithcase study let' build basic regular expression-powered templating engine in python this engine will parse text file (such as an html pageand replace certain directives with text calculated from the input to those directives this is about the most complicated task we would want to do with regular expressionsindeeda full-fledged version of this would likely utilize proper language parsing mechanism consider the following input file/*include header html **this is the title of the front page /*include menu html **my name is /*variable name **this is the content of my front page it goes below the menu favourite books /*loopover book_list **/*loopvar **/*endloop **/*include footer html **copyright &copytoday