Problem with SCons - don't understand Variables class

I am working on a SConstruct assembly file for a project, and I am trying to update it from Options to Variables, since the options are deprecated. However, I do not understand how to use variables. I have 0 python experiences that probably contribute to this.

For example, I have this:

opts = Variables()
opts.Add('fcgi',0)
print opts['fcgi']

But I get an error message:

AttributeError: Variables instance has no attribute '__getitem__':

Not sure how it should work

+3
source share
2 answers

Generally, you should store variables in your environment for later testing.

opts = Variables()
opts.Add('fcgi',0)
env = Environment(variables=opts, ...)

Then you can check:

if env['fcgi'] == 0:
    # do something
+5
source

, Variables python __getitem__ , [ ...] opts. , , , Variables , , , :

for key in opts.keys():
    print key

:

print opts.GenerateHelpText()
+1

All Articles