Is there an equivalent to the unless
statement in Python? I do not want to append a line to a label if it has p4port
in it:
for lin
There's no "unless" statement, but you can always write:
if not some_condition:
# do something
There's also the not in
operator as Artsiom mentioned - so for your code, you'd write:
if '@' in line and line == l:
lineMatch = True
line = line.strip('\n')
line = line.split('@')[1]
line = line + '
\n'
if 'p4port' not in line:
labels.append(line)
... but Artsiom's version is better, unless you plan to do something with your modified line
variable later.