All right, so welcome back again to any class session we try to see how to work with. Click right so let's see how to first of all install click the news and move on from there. So if I go back to my Moodle two folder, there's nothing so I'm going to create a folder called MKT how for this click to place we wicked nice. Now let's go inside our clip and we're going to create a sample file. I just come back to default here, create a new file and we'll be saving this particular file as busy CLR to basic CLR with pi, right you can see it has a name. Now let's see how to work with click.
So first of all let's install Click on Install just go to your terminal and click pip install. Click buy that is how to install click on your system. So in case you are using Python 2.7 which is deprecated by now because by 2020 you can use this particular option I to to install it Dennis options I can also use PIP three To install Python to install it for Python three purpose is not to be PIP three install CLI. Very interesting, very exciting. Now let's see how to work with it. So the first thing that we want to import click input click very simple.
And I'm going to create my simple function which is going to be me. So it is very important and very essential that when you are writing your CLS you put them either in functions or in classes, right that is the basic idea behind it is going to be with key to string which is going to be a simple simple CLR is very interesting. Now let's print something very simple to print. Hello CLR CL I bought this right very interesting. Interesting though good to integrate this with lotion mean all the best ways to just go with this mean? So this mean is referring to the mean find it right now.
Time I run this particular file, also going to run it perfectly for us. But that is not the best way. Right? So let's use this to evening project. So this is very good. So if name is called to mean, then run this main function we just wrote into this.
If so how would we convert this particular function into the simplest we'll get this come back to the top of the funnel and go with click command to the click command isn't this is a decorator, right click decorator that's going to convert this particular function into Seola. If I save it, and I come back to my terminal and greet Python three, then how to run the scene father to have this option. Go to list Hello, click put this to the newt convert this particular function into a new line. So I can actually go to this option of that does help and then I hope to see how to use this particular Osceola. So see how it says to that is going to be the usage, very excited with options. Then you also have a Simple COI, which is referring to this doc string, it will have the option C very interested.
That is something very cool about it. So in case I want to add a patient with a cat just come up to this place with click, go to vision option, right, then I specify the Press Club option, right, there's going to be Press Club vision is going to be 0.01. Right? It's very interesting and very useful for you to be naming your vision in this particular option, right? Then I can just go with the probe name, the problem is going to be the program name, I'm gonna call it a basic CLR. Very simple.
So if I save it, and I come back here and run it again, we're going to see our vision option there. And it's how to add version to it. Very simple. So with this simple code, you'll be able to build a simple CLA. They've given us a very nice documentation, a very nice hope that we can use. So we get to see their vision, and he's come back to this place and go with vision.
Let's bring it to the top. with Visual Basic see Li referring to the program name here. Right? And then the beige interpreter, right? We're very interested in a very simple that is how to build a simple sealer with click now let's see some other seconds to do. So how do we add options to it?
So there are several things can also do we have seen how to add a simple patient info and add an option to go to this option. As we learned that options are non mandatory and non mandatory. They are not a must in every option. Let's go with that. That is the basic idea behind it. So let's see how to create a simple option.
So a simple option is going to be at click that option, right pivot DNS argument to take it a row to take the dash that's the name of the option. So let's do something like see first name right, then you can just specify it is going to be the long format have the option here to keep the short format it is very essential to always give the long format Kunis short format is going to be a short format so there's going to be that if right for face name, then an estimator can specify a description for it. So to say this name description that is asked by civitan I come back here and let's run it again. For now go to see our first new option here, right so we have the short form long form and this is going to be the type and description first name description.
So how do you actually let it wait to allow it to work you have to pass this option into our function, right? So to be able to identify so by default to this click it automatically going to identify that this first name is the one that is being passed. Right to me changing it from here, so hello, COI but it's going to be Lucy alight Buddhists, right if it they can just print. Hello, Deline clip isn't taught format If I save it now, and let's run it again, everything is working as expected. So I can just come back to my family there specified any of us just going to print out Hello, cry Buddhists. Hello, Jesse.
Very interesting, very simple. So with this simple code, we need to add an option to it. So if you notice this was a test, right? So that is the type of diff of energy I'll give you various areas to specify spiritually specify the type. Let's come back to this type, then I'll just go with string, right try to it's going to tell me that this particular type is only for strength. We come back here, run it again.
Everything is working as expected. So what if I don't specify any as we learned that options are non mandatory, in case I go with this option, without this fight, I need to print it perfectly for us. Hello, none right? So options are non mandatory. So the best way of fixing This non aluna is that you can just specify a default value by default. And you keep the default value as we see with now.
And I come back again, I run it again without any option would be using the default Hello friend as the default rate. And this how to default to Oh, we have seen how to create a simple option using the long format initial format, and then how to add description with the help how to add a type, how to add a default value to it. Very interesting. So there's something very basic about it. Now let's see how to also add some other aspect to it. So let's add another professor click third option, which is going to be age and I'm going to keep it short format for each, then let's give help is going to be your age.
Very interesting to add a type here is going to be now in SPSS. Have any type to be at least twice a week now Don't forget to pass in the option here to age two which is going to be Hello. Quite you ages This is metaphoric your age is that we pass it not here to very interesting because I see it now this printed game so hello friend your age is not right by default keyboard the default value here and an anon also not too if I come back to the desktop hope we can see how to use it so we see that our age how they specify that is quite sweet if I come back and I run it from scratch, basically, and let's give it the age is 20 zero day just to fit this me this 20 perfect is wicked right sweet if I give it a value like let's see this 20 is working perfectly well.
So there is an intuitive way to work with magically anytime you put a type at the top here, right, it's almost clearly converted that the condition at the top right is something very interesting. Let's add something to it. This was a sprint. So the last year you will be who you will be this year you'll be this year by now, right to be adding a value added value. So it's got us here by now just give it a name. Good to be one plus two each the dependency supply.
Right. So we just had it so much. Yeah, bye. pivots or lists or anything you So what's going to give to us. So you'll be this 203 a year by now very interested to read this portion at the top here, I'm converting it automatically, but I can ignore this one here. If I ignore this one from here, and I run into it give us an error because you cannot commit, combine a string, and the number of threads given us also prototype right port supported type.
So one of the ways of serving just come back to the split and go by the hit around our age. Then if I run it is going to break previously, right. So the simplest ways that lm recommended way is to specify the top a type at the top of the option. So this is very a tweet is based in beta this one because we have a new to see how to add options to it. Now let's see how to work with multiple values. So it gives you want to receive multiple bye For a single option, let's see how to do that.
To induce was going to be like this is going to be multiple value for an option, right? Do you see multiple value or multiple ultimate for an option? So for example, let's say you have salary you want to receive multiple values so multiple estimates for salaries at 200 different police IDs for one particular option How do you need to do the simplest we'll just go with the same thing. Click that option, then our passing day long format of Arsalan can in a short format of salary. Right then from here I can specify the help going to be your salary. And I will just go with nlg that is admit to accept less accept only two By going to is only going to accept to so don't forget to pass this salary inside our function so very interested unless added to it to be print apologies for the night behind the print then we're going to be your salary your salary is that right?
Okay good now is anything good? See, you seem to know you have done so far. Let's go with the help. So, we see that we have our salary here which is a test we have ambition you have our each of our first name, it gives out a salary to with the candidates run the same thing that we did, which is this steam thing. Right. So it was going to give us as soon as empty was since we specified that this is receiving a number of argument is to go to put everything as a tuple Right, so guess I pass in that value is going to be the salary.
Salary. So I put 22,000, to receive 40,000. Let's put them together for us very interesting. So as I said earlier, if I add another value to it, it's going to give us an error, right? So goes on this credit history. If I use only one, it's also going to give us an error.
So it's very, very strict. It has to be two, two, you have to know when to use it. Very interesting. Now let's add something to eat in case you want to add a type to it can actually add types to this particular tuple. It's about the face width, I can just go with this type, then grid is going to automatically convert it into int. Then from here, I can sum it up.
So let's sum it up here. So I can just sum it up sum. This particular value here is allow us to print it. This is time before us. Come back to this place with what ultimate support that is something very cool, right with the number of arguments. So we're going to sum it perfectly for us.
Okay, so that is something interesting I've done now let's see how to add not just multiple values but in case we want to add multiple options, right? So what do I mean by multiple options? Are there multiple options that you just go with this option is going to be multiple options. Everybody can just specify something like this. See, first name right, this is going to be Jesse, and a first name. David.
David, like that, when the same auction I targeted So one of the ways of doing that is just go with the same options. Click that option. Then I just go with the first UCT then I wrote the city that is not listed. Right, get from me, I can just hope it's cool too. Your cities then from here can just go into multiple set to true. So by default, all of these options are set to what we set to once we can only use it once.
So I have to pass my city here and then have to print it print you visited satisfy cities, right? Those format then so let's save it and let's come back to them No, run our help. is going to print it bring it perfect for us, our cities, then I can actually do the same thing. See for London. So he visited London. He was dead.
He was dead, New York. Ronnie's not going to put all of them inside it for us. Very simply the basic idea behind using Multiple setting multiple to true, very interesting and very simple, very nice. Very cool. So this same thing can be applied to the face name in any of these cases. And it's how to work with multiple objects.
Now we have been using print Print to print all over. So in case you're using Python three, it was working out if I use placement to call it wait. So let's run it again. And let's use it to it's working perfectly. But this is because we are running it by trying to write it to make it work by clicking through the optional using clicked with echo to help us with this issue. Phyllis, let me show you what I mean.
So I agree to print. Hello, Python two. And this one again, as long as you did this Python two, it went quite perfectly right. If I do Python three is giving us an error right there it is giving us an error. That is right. 3d doesn't work, right?
This does not work we do have this particular option Python three. So how do you fix that issue to fix that issue? Can this come back to this place and then use click the echo instead of print want to use click.so not going to be click to click on the parts inside that particular bracket. So we did option now Could I despite them two by three is still going to wick and give us no effort. So let's save it. Let's run it again.
Bear with me to this we can dissipate on three and this one is going to while everything is okay, so the basic idea behind botnet symposia lie with click so in the next session, we try to see how to work with click not not options, but click positioner. Thank you and see in this session.