From d7949f9c4e7d70de3b5e060cb402b2d5f9f69a8d Mon Sep 17 00:00:00 2001 From: Mats Wichmann Date: Fri, 4 Jan 2019 11:26:04 -0700 Subject: 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 --- doc/man/scons.xml | 14 +++++++------- doc/user/command-line.xml | 13 ++++++------- src/CHANGES.txt | 4 ++++ 3 files changed, 17 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. 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!") @@ -3028,13 +3028,13 @@ list change on on each successive call to the function: -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 [] 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: +via the built-in Python str function: target_file_name = str(target) -source_file_names = map(lambda x: str(x), source) +source_file_names = [str(x) for x in source] 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 map function - to run the list through str: + You can do this easily by calling the str + on the elements in a list comprehension: @@ -2210,7 +2209,7 @@ prog2.c 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]) prog1.c @@ -2244,10 +2243,10 @@ prog1.c 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]) 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]) prog1.c diff --git a/src/CHANGES.txt b/src/CHANGES.txt index ccab749..6732d38 100644 --- a/src/CHANGES.txt +++ b/src/CHANGES.txt @@ -11,6 +11,10 @@ RELEASE VERSION/DATE TO BE FILLED IN LATER - Whatever John Doe did. + From Mats Wichmann: + - Update some doc examples for Py3: map() now returns an interable + instead of a list. + RELEASE 3.0.2 - Mon, 31 Dec 2018 16:00:12 -0700 -- cgit v0.12