I'm running some python as a single-line script, but getting the following error
>>> import ipaddress; (ipaddress.IPv4Address('1.1.1.1') in ipaddress.IPv4Network('1.1.1.1/32')) ? raise Exception('xxx') : pass;
File "<stdin>", line 1
import ipaddress; (ipaddress.IPv4Address('1.1.1.1') in ipaddress.IPv4Network('1.1.1.1/32')) ? raise Exception('xxx') : pass;
^
SyntaxError: invalid syntax
I've also tried:
>>> import ipaddress; raise Exception('xxx') if (ipaddress.IPv4Address('1.1.1.1') in ipaddress.IPv4Network('1.1.1.1/32'));
File "<stdin>", line 1
import ipaddress; raise Exception('xxx') if (ipaddress.IPv4Address('1.1.1.1') in ipaddress.IPv4Network('1.1.1.1/32'));
^
SyntaxError: invalid syntax
Why is this invalid syntax? Is there an alternative way that I can achieve the same end goal?
I'm running this code from a third party tool (terraform) so it has to be a single-line script.