Dynamic text should have an new type: py
In the property field one could write code, that will evaulate and be passed to the dynamic text.
For example (result would be same as <dyn type="page" property="number"/>:
<dyn type="py" property="arcpy.mapping.MapDocument("CURRENT").dataDrivenPages.currentPageID"/>
Allows for full flexibility, and access to specific layers as well as their fields and attributes. In addition, multiple lines of code can be separated with \n, similar to when code must be entered into calculate field as a tool.