Hey, welcome back.
In this video, you'll learn about static methods.
Let's create a static method in the reservation ticket class.
To create a static method, you use the static method decorator.
A followed by the definition of the method.
Let's say, convert.
Now you see, that poncho didn't even suggest me to use a self argument.
So static methods do not get a self argument or a c else argument.
A static method is like a function, so it doesn't have any reference to the class.
Or it's instance, let's say we have a mount as a variable.
And return amount.
Times 1.2.
Now, what is this, anyway?
Well, let's imagine that.
We we are generating the ticket, but we need some utility function to convert the price from euros
to USD.
So this is some sort of utility function, right?
But since this function is somehow related to producing the ticket, because we want to have that converted
price inside the ticket, then it makes sense to have that method inside the class so that later on
you can basically call that static methods using reservation ticket that converts.
And here you'd give the amount like ten.
Perhaps you store this in variable converted and then you can use the variable somewhere else in the
code.
But let's just print it out in here, print, convert it.
And so we get 12.
So ten times 1.2, we get 12.
So that would be an example of a static method.
Now, the distinction between static methods and class methods is a bit blurred, but usually you won't
use static methods when you want to do some utilities like as we had here, converting that number.
So conversions are usually a very used case.
And so this method here is less associated with its class compared to this class methods.
Both class methods and static methods are rarely used compared to instance methods, but it's good to
know what they are.
So I hope this makes sense.
And in the next video you learn about magic methods which are very interesting.
So I'll see you there.