mirror of
https://github.com/xonsh/xonsh.git
synced 2025-03-04 00:14:41 +01:00
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:
parent
2d07ae8698
commit
c84420e7b3
1 changed files with 12 additions and 0 deletions
|
@ -135,6 +135,17 @@ variable in Python. The same is true for deleting them too.
|
||||||
Become the Lord of the Files
|
Become the Lord of the Files
|
||||||
>>> del $GOAL
|
>>> 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.
|
Very nice.
|
||||||
|
|
||||||
.. note::
|
.. note::
|
||||||
|
@ -142,6 +153,7 @@ Very nice.
|
||||||
To update ``os.environ`` when the xonsh environment changes set
|
To update ``os.environ`` when the xonsh environment changes set
|
||||||
:ref:`$UPDATE_OS_ENVIRON <update_os_environ>` to ``True``.
|
:ref:`$UPDATE_OS_ENVIRON <update_os_environ>` to ``True``.
|
||||||
|
|
||||||
|
|
||||||
The Environment Itself ``${...}``
|
The Environment Itself ``${...}``
|
||||||
---------------------------------
|
---------------------------------
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue