Show More
@@ -0,0 +1,1 b'' | |||
|
1 | * Enhanced support for `env` magic. As before, `env` with no arguments displays all environment variables and values. Additionally, `env` can be used to get or set individual environment variables. To display an individual value, use the `env var` syntax. To set a value, use `env var val` or `env var=val`. Python value expansion using `$` works as usual. |
@@ -380,7 +380,16 b' class OSMagics(Magics):' | |||
|
380 | 380 | |
|
381 | 381 | @line_magic |
|
382 | 382 | def env(self, parameter_s=''): |
|
383 |
""" |
|
|
383 | """Get, set, or list environment variables. | |
|
384 | ||
|
385 | Usage:\\ | |
|
386 | ||
|
387 | %env: lists all environment variables/values | |
|
388 | %env var: get value for var | |
|
389 | %env var val: set value for var | |
|
390 | %env var=val: set value for var | |
|
391 | %env var=$val: set value for var, using python expansion if possible | |
|
392 | """ | |
|
384 | 393 | if parameter_s.strip(): |
|
385 | 394 | split = '=' if '=' in parameter_s else ' ' |
|
386 | 395 | bits = parameter_s.split(split) |
@@ -402,7 +411,9 b' class OSMagics(Magics):' | |||
|
402 | 411 | string. |
|
403 | 412 | |
|
404 | 413 | Usage:\\ |
|
405 | %set_env var val | |
|
414 | %set_env var val: set value for var | |
|
415 | %set_env var=val: set value for var | |
|
416 | %set_env var=$val: set value for var, using python expansion if possible | |
|
406 | 417 | """ |
|
407 | 418 | split = '=' if '=' in parameter_s else ' ' |
|
408 | 419 | bits = parameter_s.split(split, 1) |
@@ -24,6 +24,18 b' the default profile such that:' | |||
|
24 | 24 | * turn ``%autocall`` to full mode |
|
25 | 25 | |
|
26 | 26 | |
|
27 | Environment variables | |
|
28 | ===================== | |
|
29 | ||
|
30 | Rather than manipulating os.environ directly, you may like to use the magic | |
|
31 | `%env` command. With no arguments, this displays all environment variables | |
|
32 | and values. To get the value of a specific variable, use `%env var`. To set | |
|
33 | the value of a specific variable, use `%env foo bar`, `%env foo=bar`. By | |
|
34 | default values are considered to be strings so quoting them is unnecessary. | |
|
35 | However, python variables are expanded as usual in the magic command, so | |
|
36 | `%env foo=$bar` means "set the environment variable foo to the value of the | |
|
37 | python variable `bar`". | |
|
38 | ||
|
27 | 39 | Aliases |
|
28 | 40 | ======= |
|
29 | 41 |
General Comments 0
You need to be logged in to leave comments.
Login now