This change came because of Python scripts for experiments now being modular - allowing just a particular part of an experiment (e.g. just running the flow, just showing the expInfo dialog, just setting up the window) to be run without having to run the whole script. This necessitated significant changes to how scripts were written - we wanted these variables to be available as soon as possible so put them at the top of the script, but that does mean variables defined in Before Experiment aren’t available… So I think you’re right that these definitions should happen after Before Experiment code.
As a temporary fix, you could use a placeholder value in expInfo
from the experiment settings and then set it in the same Code component instead, like so:
myValue = <whatever>
expInfo['myParam'] = myValue