From c84420e7b35c3a61a0a76074cd43510d51182dc5 Mon Sep 17 00:00:00 2001 From: Shawn Wallace Date: Thu, 31 Oct 2024 05:33:45 -0400 Subject: [PATCH] Add examples of environment variable interpolation (#5714) * Add examples of environment variable interpolation * Update tutorial.rst * Update tutorial.rst --------- Co-authored-by: Andy Kipp --- docs/tutorial.rst | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/docs/tutorial.rst b/docs/tutorial.rst index 02d5d11bc..5ee4b2f4b 100644 --- a/docs/tutorial.rst +++ b/docs/tutorial.rst @@ -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 ` to ``True``. + The Environment Itself ``${...}`` ---------------------------------