I'm trying to understand the first part of the next validation. Can I safely assume that the expression 'if not set(sys.argv)' is always False? Code is from the Ironic Project.
if not set(sys.argv) & valid_commands:
According to the docs, if the command is run with '-c' option, argv[0] is set to the string '-c'. Which is still a non-empty set. Example:
python -c '
import sys
print(sys.argv[0])
if not set(sys.argv):
    print("empty")
else:
    print("non-empty")
'
				
                        
You're reading it wrong. Python's
nothas very low precedence, below that of&(which isn't logical AND).should be read as
which is testing whether
sys.argvcontains any elements of the setvalid_commands.