Add examples of environment variable interpolation (#5714)

* Add examples of environment variable interpolation

* Update tutorial.rst

* Update tutorial.rst

---------

Co-authored-by: Andy Kipp <anki-code@users.noreply.github.com>
This commit is contained in:
Shawn Wallace 2024-10-31 05:33:45 -04:00 committed by GitHub
parent 2d07ae8698
commit c84420e7b3
Failed to generate hash of commit

View file

@ -135,6 +135,17 @@ variable in Python. The same is true for deleting them too.
Become the Lord of the Files
>>> del $GOAL
>>> $NUM = "123"
>>> $EXT = $NUM + "456"
>>> $EXT
'123456'
>>> $FNUM = f"{$NUM}456" # Not working with Python 3.12+ (https://github.com/xonsh/xonsh/issues/5166).
>>> $FNUM = "{FILLME}456".format(FILLME=$NUM)
>>> $FNUM
'123456'
>>> "%s456" % $NUM
'123456'
Very nice.
.. note::
@ -142,6 +153,7 @@ Very nice.
To update ``os.environ`` when the xonsh environment changes set
:ref:`$UPDATE_OS_ENVIRON <update_os_environ>` to ``True``.
The Environment Itself ``${...}``
---------------------------------