There is the possibility to add python code to the QGIS form startupattribute forms which will be executed when it opens. To configure it go to the Fields tab in the layer properties and change the Python Init Code combobox.
If you choose Provide code in this dialog you will see the code. As long as this combobox is set to a different entry the code will not be executed. The code which you see is the default template for the code.
N.b. python code does not require a return
statement to be working.