Some context
I need to emulate the behaviour of the shell command source but in Python. Specifically sourcing tcsh scripts, but it would be nice for it to be as generic as possible.
I've seen this answer where it makes the shell run env to print all environment variables.
My question
env or printenv only prints environment variables but not local variables. However the tcsh scripts I want to source use commands like
set FOO=bar
So is there a way in tcsh (and other shells, just for completeness) to print all local variables?
Edit: Yes I know I'd have to run TCSH as a subprocess for it to parse the script, and yes python can't read into TCSH's memory which is why I want a way to print all local variables within TCSH so Python can read them.