summaryrefslogtreecommitdiffstats
path: root/doc
diff options
context:
space:
mode:
authorMats Wichmann <mats@linux.com>2019-01-04 18:26:04 (GMT)
committerMats Wichmann <mats@linux.com>2019-01-04 19:45:56 (GMT)
commitd7949f9c4e7d70de3b5e060cb402b2d5f9f69a8d (patch)
tree256460d829d2b582d444396969eb2104db46ce77 /doc
parentd2e6e13d697412b8d60ff30fc812f7d905e5e8f6 (diff)
downloadSCons-d7949f9c4e7d70de3b5e060cb402b2d5f9f69a8d.zip
SCons-d7949f9c4e7d70de3b5e060cb402b2d5f9f69a8d.tar.gz
SCons-d7949f9c4e7d70de3b5e060cb402b2d5f9f69a8d.tar.bz2
Update some doc examples
map() now returns an interable instead of a list, update examples which assumed they could just print() the result of a map(). Signed-off-by: Mats Wichmann <mats@linux.com>
Diffstat (limited to 'doc')
-rw-r--r--doc/man/scons.xml14
-rw-r--r--doc/user/command-line.xml13
2 files changed, 13 insertions, 14 deletions
diff --git a/doc/man/scons.xml b/doc/man/scons.xml
index f61c491..805164c 100644
--- a/doc/man/scons.xml
+++ b/doc/man/scons.xml
@@ -3014,7 +3014,7 @@ function to get at the path name for each Node.</para>
<literallayout class="monospaced">
print(str(DEFAULT_TARGETS[0]))
-if 'foo' in map(str, DEFAULT_TARGETS):
+if 'foo' in [str(t) for t in DEFAULT_TARGETS]:
print("Don't forget to test the `foo' program!")
</literallayout>
</listitem>
@@ -3028,13 +3028,13 @@ list change on on each successive call to the
function:</para>
<literallayout class="monospaced">
-print(map(str, DEFAULT_TARGETS)) # originally []
+print([str(t) for t in DEFAULT_TARGETS]) # originally []
Default('foo')
-print(map(str, DEFAULT_TARGETS)) # now a node ['foo']
+print([str(t) for t in DEFAULT_TARGETS]) # now a node ['foo']
Default('bar')
-print(map(str, DEFAULT_TARGETS)) # now a node ['foo', 'bar']
+print([str(t) for t in DEFAULT_TARGETS]) # now a node ['foo', 'bar']
Default(None)
-print(map(str, DEFAULT_TARGETS)) # back to []
+print([str(t) for t in DEFAULT_TARGETS]) # back to []
</literallayout>
<para>Consequently, be sure to use
@@ -5279,11 +5279,11 @@ arguments may be lists of Node objects if there is
more than one target file or source file.
The actual target and source file name(s) may
be retrieved from their Node objects
-via the built-in Python str() function:</para>
+via the built-in Python <function>str</function> function:</para>
<literallayout class="monospaced">
target_file_name = str(target)
-source_file_names = map(lambda x: str(x), source)
+source_file_names = [str(x) for x in source]
</literallayout>
<para>The function should return
diff --git a/doc/user/command-line.xml b/doc/user/command-line.xml
index f26c179..1b329e7 100644
--- a/doc/user/command-line.xml
+++ b/doc/user/command-line.xml
@@ -2200,9 +2200,8 @@ prog2.c
internal &SCons; nodes,
so you need to convert the list elements to strings
if you want to print them or look for a specific target name.
- Fortunately, you can do this easily
- by using the Python <function>map</function> function
- to run the list through <function>str</function>:
+ You can do this easily by calling the <function>str</function>
+ on the elements in a list comprehension:
</para>
@@ -2210,7 +2209,7 @@ prog2.c
<file name="SConstruct" printme="1">
prog1 = Program('prog1.c')
Default(prog1)
-print("DEFAULT_TARGETS is %s"%map(str, DEFAULT_TARGETS))
+print("DEFAULT_TARGETS is %s" % [str(t) for t in DEFAULT_TARGETS])
</file>
<file name="prog1.c">
prog1.c
@@ -2244,10 +2243,10 @@ prog1.c
<file name="SConstruct" printme="1">
prog1 = Program('prog1.c')
Default(prog1)
-print("DEFAULT_TARGETS is now %s"%map(str, DEFAULT_TARGETS))
+print("DEFAULT_TARGETS is now %s" % [str(t) for t in DEFAULT_TARGETS])
prog2 = Program('prog2.c')
Default(prog2)
-print("DEFAULT_TARGETS is now %s"%map(str, DEFAULT_TARGETS))
+print("DEFAULT_TARGETS is now %s" % [str(t) for t in DEFAULT_TARGETS])
</file>
<file name="prog1.c">
prog1.c
@@ -2338,7 +2337,7 @@ else:
prog1 = Program('prog1.c')
Program('prog2.c')
Default(prog1)
-print ("BUILD_TARGETS is %s"%map(str, BUILD_TARGETS))
+print ("BUILD_TARGETS is %s" % [str(t) for t in BUILD_TARGETS])
</file>
<file name="prog1.c">
prog1.c