Hey, friends.
Welcome back.
Now let's go and change our program in a way that we can use it in a better way.
Okay, now, for example, I'm going to write Python and then Mac Changer dot Pi.
I want to specify the interface like dash I or dash interface, and then eta zero.
And then like dash M is going to be Mac address okay.
Like this.
So how can I do this.
It is not very easy to do it okay.
Because we need to specify this that these program understand this okay.
Or get this argument from here not from inside the program.
So it is very easy if we use a module called Optparse or Optparse.
So let's use that okay I'm going to import that is Optparse and I'm going to use it here okay.
So first we need to create its object.
Let's name it parser.
It is equal to Opt R dot.
Opt.
Parse.
Parser.
Let's remove this and write it from the beginning.
It is OP sorry.
It's option.
Parser.
So it is a function okay not a function is a class because it is start with capital.
Capital letter.
Anything that is started with capital letter.
Yes.
Remember that is a class and it has a lot of child and a lot of like methods function that we can use
it.
Okay.
So here we have this parser right now which is an object.
It has other function like adoption like a lot of things that we can use it okay.
So here let's use it I'm going to say add ops parser dot add option.
Add option is a method okay that here we can use it okay.
So here I'm going to give dash I y dash I that means interface.
If someone gives Or provide that I and the program should understand that it is an interface or the
user could enter interface.
Okay.
So this board is going to be this is equal to enter paste okay.
If someone write I or dash interface that means it is going to be interface okay.
So it will get this interface from output.
And then or we can write a help here okay.
Help is equal to.
Help is equal to let's say interface to change it.
Make it interface to change its.
Mac address.
Now let me save this.
And here I am going to Use.
Partial dot.
Uh.
Hours.
Okay.
Now call it.
And.
I'm going to execute this.
Okay.
Let's come right in here.
Okay.
We have it.
So we have Mac Changer.
And now let's specify Dash I.
And this interface is going to be either zero okay it is zero or let's go with dash help.
Dash dash help.
Let's hit enter.
Now you see that I have an error here.
And it is say option passed object has no attribute pass args okay.
And that is my problem okay.
Here we have a misspelling I think okay.
It is not a r g e it is a r Gee, is that was my mistake.
Sorry.
Let's execute this again.
And here.
Now you see that it gives you options.
Dash h or dash?
Dash.
Help show this help message and exit.
So see we have dash I which is equal to interface and interface.
And also it says that interface to change its Mac address.
Okay.
And it is saying that if you use Dash I with this it will change the interface.
And also the help that this text that we write okay.
Interface to change its Mac address.
It is the text that we just write here.
Okay.
Write it down here.
So now you learn okay slowly that how can we get an argument from user from output.
So from terminal.
Okay.
So now let's go and see how we can get all and everything which was interface and also new Mac address
and how we can use it down here to interact.
So let's go and see that.