AttributeError: OptionParser instance has no attribute 'interface'

import subprocess
import optparse

parser = optparse.OptionParser()

parser.add_option("–interface", dest=“interface”, help=“Interface to change the Mac address”)
parser.add_option("–mac", dest=“new_mac”, help=“New Mac address”)

(options, arguments) = parser.parse_args()

subprocess.call([“ifconfig”, parser.interface, “down”])
subprocess.call([“ifconfig”, parser.interface, “hw”, “ether”, parser.mac])
subprocess.call([“ifconfig”, parser.interface, “up”])

I get the following error:

subprocess.call([“ifconfig”, parser.interface, “down”])
AttributeError: OptionParser instance has no attribute ‘interface’

Can someone please help me with this?

There is no ‘interface’ in OptionParser. For accessing the values of the arguments, you need to use ‘options’ variable or ‘arguments’ variable, where you are taking the arguments in.

My bad. Got it.
Thanks