[Scons-users] env.Dictionary bug? doc problem?
Bill Deegan
bill at baddogconsulting.com
Sun Jul 22 14:26:38 EDT 2018
Can you check if any internal usage depends on this slicing behavior?
-Bill
On Sun, Jul 22, 2018 at 11:18 AM, Mats Wichmann <mats at wichmann.us> wrote:
> === manpage:
>
> env.Dictionary([vars])
>
> Returns a dictionary object containing copies of all of the
> construction variables in the environment. If there are any variable
> names specified, only the specified construction variables are returned
> in the dictionary.
>
> Example:
>
> dict = env.Dictionary()
> cc_dict = env.Dictionary('CC', 'CCFLAGS', 'CCCOM')
>
>
> But testing exactly that example -
>
> === SConstruct:
> env = Environment()
> dict = env.Dictionary()
> print("dict: " + str(type(dict)))
> cc_dict = env.Dictionary('CC', 'CCFLAGS', 'CCCOM')
> print("cc_dict: " + str(type(cc_dict)))
> print(cc_dict)
>
> === output:
> scons: Reading SConscript files ...
> dict: <type 'dict'>
> cc_dict: <type 'list'>
> ['gcc', [], '$CC -o $TARGET -c $CFLAGS $CCFLAGS $_CCCOMCOM $SOURCES']
> scons: done reading SConscript files.
>
>
> And that's pretty easy to see in the code, which uses a list
> comprehension if there are arguments, extracting only the values and
> ignoring the keys.
>
> def Dictionary(self, *args):
> if not args:
> return self._dict
> dlist = [self._dict[x] for x in args]
> if len(dlist) == 1:
> dlist = dlist[0]
> return dlist
>
> If the documentation is correct, what we really want is a "dictionary
> slicing" type of operation (maybe using itertools, maybe using a
> dictionary view object).
>
> _______________________________________________
> Scons-users mailing list
> Scons-users at scons.org
> https://pairlist4.pair.net/mailman/listinfo/scons-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://pairlist4.pair.net/pipermail/scons-users/attachments/20180722/0eaa3055/attachment.html>
More information about the Scons-users
mailing list