'Is there a nice way to use the %env magic to *append* to an environment variable?

For example, I wanted to append to the PYTHONPATH environment using the %env magic. The only way I could figure out requires setting a "dummy" python variable and using two lines:

PYTHONPATH = %env PYTHONPATH 
%env PYTHONPATH = $PYTHONPATH:/additional_dir

Is there a simpler way?

For example, in bash one simply does

export PYTHONPATH=${PYTHONPATH}:/additional_dir

I was expecting that something analogous was possible with %env.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source