AirBnB Clone Console Application in Python Discussion | ALX PLD

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
Airbnb clone project and basically we are going to try to understand what this project is about and how to approach it if you haven't done it yet and basically this is like the first Main web project that we are doing so all the projects that we have done so far isn't related to having a website this is the first one that is related to having a website and to be able to accomplish this project or be able to build a clone of the Airbnb website you would have to there are certain things that you need to appreciate be able to do okay and as a software engineer peculiar thing that we need to know about rates we haven't come across yet so probably ask me about there is something we call the software let me make a smaller to the software developments life cycle software development life cycle which is mostly abbreviated as the sdlc so if you come across it anywhere and basically this is like a framework that indicates exactly what happens when it comes to building a software okay so there are a lot of processes that take place when you want to build a software and even though there are variations of it the common form that you find is that to build a software you would first start with planning so that's the first stage of the software development life cycle you start with planning then after you're done planning you do what we call analysis okay analysis or some of them will say uh requirements analysis requirement analysis then the third one after you are done with your analysis and everything you do into the design phase where you design or come up with the design related details okay regarding the software that you're going to build then the fourth they should documentation is implementation state that is basically where the actual building is the actual building of the the software is here then after you are done building the software what you're going to do is you're going to test so the first stage is testing then the final stage is mostly maintenance okay so the final stage is mostly maintenance but then it's a cycle maintenance is a cycle that means even from the main stage you still keep planning and if there is need to go through it again I mean do more analysis you may be doing Visa updates and things so this is a whole cycle that you go through everything and as a software engineer it's something that you must know um uh when you are working in a company where you have a lot of specialization everyone has what they are expected to do you may find yourself in just one or two of these parts let me usually testing some people who include integration integration here then before maintenance others will include deployments so depending on which one you are using but then if mostly for the planning if you are working in a big company the planning may not even get to your side like your bosses or the superior will do all the planning some people will be called on to do the analysis and requirements and depending on what exactly you are responsible for so when you come to the design Parts mostly to develop a software they will come up with what we call the the s software specification requirements yes I think too then they may also come up with we call the design uh document requirements okay so that is also there but then in this particular case that we are building the clone of an lbmb project the whole thing is like you are building your own website from scratch okay so the planning all of these things is on you the fortunate thing is that this is a clone and because it is a clone most of the work has been done for us we just need to go and understand what has already been done okay then we will now replicate what has been done if you don't understand what has been done you can replicate it if we were supposed to build our own projects without contributing the clone of something we will now have to sit down and do the planning ourselves we have to do the analysis see what requirement what tech stack are we going to use come up with a design so sometimes even here we have to do what we call wireframing uh prototyping and UI ux design research and things okay so all of those things will come in then eventually after you've got in the design that you want you've got you have in mind exactly what you want to be building then you come down to write the code which is the four that's the part four okay then when it comes to implementation itself we look at for such a case that is a web app for a web app we are looking at three major parts of the web app when you are building we are looking at one the front end of the web app that's the front-end design we'll look at uh what we refer to as the back end design then we'll look at the database the database design database for us specific case we are here to look at databases I think in the coming weeks that's what we are going to be looking at so for now we would call this storage and we are going to be using 0.8 the data that we are collecting in a file the back end is like the logic of the whole website at the end of the day if somebody visits the Airbnb website and clicks a button what actually happens if they create an account what actually happens beneath it that they are not seeing so that is your uh the work that you are going to do for the back end then the front end is just the design that you are going to see and be able to interact with a website so unfortunately we are not yet we haven't done front-end design yet so for that matter in this specific case we are asked to use a console to represent our front end so we are going to build our application as a console application that means that whichever user that is going to interact with our application is going to interact through a console so the interface they will see is a console so in relation to how web app is built we'll see that is our front end okay so in this specific uh program that we are building or app that we are building we have our front end to be a console application and this console application in Python we are going to achieve that with the help of a model called the CMD model the CMD model is going to help us achieve this console application at the front end of it with the back end we've done a lot of python so far and we are going to use the oop Concept in Python that we have learned already that is the object oriented programming Concepts that we have done already please if if you're not speaking kindly mute yourself otherwise there are some distractions if you are mute yourself I expect you to either ask a question make a contribution anything of that sort okay so kindly meet yourself if you are not speaking thank you all right so with the back end we are looking at using the OB Concepts that we've learned building classes creating methods and calling this methods class attributes like all those things inheritance polymorphism encapsulation all those things that you have learned which we are going to delve into details in subsequent uh pld sessions but then this focus is on our project then when we come to the database in our case since we are not working with database we are looking at file storage so let me put it here file storage so with the file storage in Python we are supposed to uh use a model called the Json motor so with the adjacent model to help us store the data that we are generating inside a file okay so how many modules so far we've talked about the CMD model we talked about JC model great then after we have built this application that is the stage four that we are okay fortunately for us it's a closer we are building so I said what the planning has been done already requirements analysis has been done already design has been done already so we are to build OS is to build and to tests so there are two major things that we are doing we are going to build and test so the last part that we are going to do is the testing parts okay testing testing so we're testing inviting my way to use hi Kristen okay in in testing we are going to use a model called Unit tests thank you test model so these are the requirements that we've been asked to use in order to build a whole application that we are building we need to know about the CMD model so when you are learning python you didn't learn specifically about these individual models okay but then once you know how to use a model in Python you should be able to access any model learn about it and be able to use it to implement anything you want so right now we have to go and read about a CMD model what it is used for and how to use it how to implement it for us to be able to implement the front end of our projects then we also have to learn about the Json model to help us appreciate how to store our data then we'll learn about the unit test to help us what test the program or write various test cases for the projects that we are working on and all of the spots like every part is very important some of us we tend to ignore some like testing is not important it's very important there are even uh specialization sort of so if you work for a bigger company there could be a case that you as a software engineer you actually work in a testing team and all that you do is to write test cases for the software that they produce in that company okay if you are working for a startup or you're working for yourself you will find yourself doing multiple of these things that is why as we are developing ourselves as full stack Engineers we need to appreciate all of these things so let's go on now the most important part of our application is the back end we need to build our back end after we build the back end we can now connect the back end to the storage so that any data that is being processed in the back end can be stored when we process the data and store it we should also be able to Now display the data in a way that will be meaningful to the user so work on the front end depending on which company you are working with what their requirements are whether you are working a known or you're working with a team all of these things may be done concurrently or one after the other if you are building Some people prefer to build a front-end first others prefer to build the back end first others prefer to build a database okay but obviously the testing is like the last part I mean not necessarily the last last part but then you should have something to be able to test it okay so what we are going to do in our case let me see the back end but then before we'll be able to build the back end we have to analyze remember that we should have done planning analysis and things we have to analyze the Airbnb website anal analysis of the Airbnb website because that's what we want to do and know exactly what is there so when I go to Airbnb website what can I do there what is the purpose of that website you and I know that Airbnb is a platform where you can book an Airbnb now they've gotten to that status where you can say you're booking an Airbnb and everybody understands it okay but what it basically means is that you are booking a room that you are going to stay in for maybe a short period of time or depending on what your requirements are and there are specifications room that you want how many people and the room accommodate anything like a hotel we are going to book a hotel so there are things I will need to know about it for example we need to know that on that website we'll be required to create an account so we should have user accounts this user should be able to create an account add what are they going to add so if you are the only one planning these things when you know that okay a user should be able to create an account then now you start thinking if I am going to store the user details in the database what are the fields that I'm going to store for this given user okay so do I need let's say name do I need an email of the person what else do I need a unique ID so let's call it a unique ID what else do I need where they come from how long they are going to stay no no so this is not a booking part this is just the account okay so we can focus on things that will identify them when they created the account so accounts created dates then anytime they update the account we may collect the updated dates and you you decide exactly what to write so the best would be for us to go to Airbnb to their website and try creating an account and see all the integrity's details that they require all the details that they require of us then we will be aware of but for this project fortunately for us all those things have been done for us and we are told what fails to go after okay so you and I are not going to worry ourselves about whether we need the name the email the unique ID whatever we need all of those things have been mentioned for us so we just need to know that if I'm creating a user account there are a few things that I need and here I did so apart from having a user accounts we may create a towards reviews so there could be a reviews model that could be a place model to list a place if somebody wants to list their room there could be a place model that could be for each place to we are looking at the amenities that are present in that place so these are some of the models that you are going to be creating but then it all depends on how the uh platform that you are building works okay so now the best way to know how to build something on your own is by learning how others are built there so we are currently learning how Airbnb built this and this is the process that's taught about okay what what will we be looking out for on our website and some of these things we are talking about you can't you're talking about reviews we are talking about place we are talking about amenities so to implement this in Python and to make it easy since we are using the oop concept what it means is that all of these models that we are talking about we're actually going to be implementing them as what classes they are going to be implementing these as classes so that anytime a user account is created we'll just call a user class and within a class what do we have we have attributes and methods the attributes are like providing uh information details then the method is like the behavior or actions what can be done okay so for instance let's say when I create an amenity let me call it an instance here since we have some knowledge in oop if you have created a class okay a class is just a blueprint that we use so if I say I have created an amenity class all that it means is that I have a blueprint that I follow anytime that I'm creating something relating to amenity okay and anytime I create something with lots blueprints I call it the instance of the class or technically you call it an object of the class okay so when I want to create an object on this class I can go ahead and create it then I call any of the methods and use any of the attributes as and when I want so for each of the models here or objects that we are going to create on the classes these flows that we are going to be storing in our databases in our case in our storage or our file they are going to be the attributes of the class so if I ask you what are the attributes on the user accounts or user class we are looking at the name the email the unique ID they created our time they updated our time all those things become what the attribute of the class but then we should also be able to see the methods of the class so there is a common thing that most web application will do we call it the crude or crowd depending on who taught you English which where C stands for C stands for creates so I can create a user I can create a review I can create a place I can create an amenity inside my database okay and how will I be able to do that with the help of the classes that I'm writing I'll be able to do that then I can r r is for read so I can read data that I have stored I can't show this data if the user wants to see their details their profile accounts they are bookings the reviews that they have let the amities that are available inside a giving room they are waiting towards read so I can read information that I have stored then you is for you is for updates once I've stored data I can always go in and update it then finally D is for delete so most commonly when you are building a web application these four actions are things that you are going to be doing often so it means that we have to create methods that will permit us to create objects read objects update object or delete objects so these are going to be some of the methods that we are going to be creating for that matter all right any questions so far any questions I hope you are following okay so let me will rise that for some of these like reviews for reviews to I definitely need in fact when you are storing data in a database hopefully from next week convert 7 members will start learning about databases so that will be covered soon there is in in this case we are going to be using what we call a relational database because these things are linked in one way and we want to connect them based on their links and then let me not even go there what you have to take note of is that for each data that you are storing there has to be a unique ID that you can use to identify it with so if we go through all of them you realize that each of these we are going to have a unique ID field in the stories or attributes for it apart from the unique ID will also have the time that it was updated or the time that it was created so essentially what I'm saying right now is that there are some attributes that will run through all the classes that you're going to create they are giving attributes that will run through all the classes that we are going to create then there are methods like this create read High Tony hi Tony hello good evening are you saying good evening oh oh sorry about that sorry okay okay sure all right so there are some just as the attributes that run throughout all the classes that we are going to create as we have just realized there are some methods that will also run through for instance for each method we are going to create something we are going to read something we are going to update something and we are going to delete something because all of these are available in each of the classes we can abstract that and create one big class that would become the backbone of every other class that we are going to be creating okay so we decided to call that streaming class base model so this is a class that we are going to create and by now you know how to create a class in Python so there's a class that we are going to create and inside this class what are we going to do we are going to see I thought I was in my terminal we are going to Define attributes that are common amongst all the classes then we'll also Define methods that are common among all the classes so that's basically what we are going to do inside this class base model class then what it means is that when we begin to create any of the other classes say the user class all that we have to do is to make this user class inherit from the base class as soon as we make the user class inherit from the base class it inherits or the base class yeah let me call it sorry the base class attributes it will also inherits all that this class thank you methods then since there are some attributes that will be unique to just the Euler class for instance if we are storing an email we comes to an email for the place the place doesn't have an attribute called email amenity will not have an attribute called email but immunity can have an attribute called quantity quantity user name or user class cannot have an attribute called quantity so there are some of the attributes that are unique to specific classes so if I come to this class I'm then going to now declare all the unique attributes of this class and if there is a method that is also supposed to be unique to this class I'll declare the unique methods of this class give me a second I'm coming okay sorry let me know this year all right so we are going now we build a base model that contains all the details that I mean the attributes that are common for all the classes the methods that are common for all the classes then we come and build each of them each of them in fact since most of the implementation are for this specific project most of implementation is in a base model all the methods that we need is inside the basement model so you are going to Define all your methods inside the base model then as soon as you come to create the sub classes this let's say I mean unity all that you are going to be doing in here is inheritance from the base model then passing what uh the unique attributes that is all as soon as you pass your unique attributes yes right I meant attributes as soon as you pass your unique attribute here they inherit everything from the base model and you are done with that so all that you need to focus more on is building the base model to work exactly how it's supposed to work so that any of them that's inherit from it will also work that same way so we can now go ahead and create for all of this and in fact all of them the things that we needed to create I mean the subclasses that we needed to create they have all been provided for us so you can look at them and go ahead and create them after this is done the next thing is our storage how do we store the files and the data that we'll be playing with remember everything in Python is what's everything inviting is anyone to answer that everything in fighting is and thank you it's an object everything in Python is an object so in your base model the data you are collecting if you want to go and store it it is an object like it's in the form of an object so we're going to store it it means that if you don't do anything about it you are going to store it as an object the challenge is that when you store the data as an objects obviously storing it in a file will be converted into a string the next time you are pulling it from the file you are going to get your object in a form of a string it's not easy to work with an object in the form of a string so it is not advisable for you to store the data in the form of an object in a file because when you need it will be difficult for you to use it the other reason too is that this data that you are collecting you may not be the only person using that data somebody somewhere probably you develop this thing into an API that others can call on their front end applications to use the data that you have or that same data that you are collecting into a file you may want to use some analytic tool to analyze it but unfortunately if you stored it as a python object most of those uses become useless like no one can use it outside python or python no one can use it outside Brighton okay for that matter there is something that we need to do we need to prepare this object for storage prepare the objects for stories finding me for the spelling mistakes objects for stories okay and how do we do that we've realized that the best way to store search data is to convert it to Json strings and store that in files the reason is that it is easy for us to convert Json strings back through writing objects it's easy so if I prepared my objects for storage I converted it into a Json string and stored it in a file anything that I need that for I just go and call it I mean I went and pull out the data read a date enough file and I'm able to get back the adjacent string which I can easily convert remember I mentioned something about a model that we are going to be using called the Json model so with the help of the Json model we can always convert our Json string back to a python object then the other Advantage is that now that we are storing it in the form of a Json object or sorry adjacent string in a file we can do anything with any other programming language on the data that we are storing so we can have our application as an API that others will be importing the data from to use build your own front end we could have data analytics team using our data and use via different softwares or programming languages to analyze the data that we are storing okay so the process of converting our python object into the Json format that we can store so that we can easily assess any time that we want is called serialization those of you who hear about civilization and you don't understand it's basically converting this fighting object in in the context of what we are doing it's basically converting this fighting objects that you have gotten into a format that can easily be stored and retrieved at any time and also into a form that can be used across various places so that is serialization once we've been able to serialize the data we've stored it as suggesting string inside the file anytime that we need it back we just have to grab our what our string the Json string from the file so we open the file read what is there after reading it we can then convert it back into a python object doing that is the opposite of serialization so we call that deserialization all right so since we now realized that this serialization this realization thing converting Jason to python it actually isn't directly related to any of these classes that we have already the best model class the user class the amenity class it has nothing to do with them so then we go ahead to create a different class for it stories file storage class so we call that the file storage class we create that class sorry and this file storage class will be responsible for managing what the attributes related to the file that we are going to store attributes related to power then methods related to file remember that we are working with a file and there are things that we can do or we want to actions that we want to take on the file okay so methods related to the file at all even the process of converting from the python object to the Json string we are going to create a method to help us do that all right so by doing this we capture all of them under file storage and faster it will help us achieve that goal please give me a few seconds okay yes yes any any questions I'm going to the next page any questions so far any questions so far can you all hear me come again all these notes be made available to us okay okay sure so once once we are done I'll save it as a PDF and make it available yeah thank you yes good evening uh you're welcome um all right so let's go to next page what have we talked so far have we we've looked at a base model class and we said that the backbone for all the extra classes that we'll be creating but then we also needed a file storage class to handle the storage aspect of it of the file for us okay so the biggest challenge that you are going to be facing is how you are going to link the basic model such that it's going to be able to I mean link the base model with the file stories in fact in your own implementation you could have decided that hey let me put the I'm not going to create a new class called file storage every other thing that I need for my power storage I'll capture it in my base model hi Vespa hi Vesta please if if you're on mute I expect you to see like you're about to say something otherwise best are you saying something all right sure okay so if you are doing your own implementation you could have decided that okay I'm going to use everything inside this model but then that's not the most appropriate thing when we are doing op the the the advantage of doing oop or creating classes is that it makes our code reusable so today you are building Airbnb clone and you need file storage what if tomorrow are building a different project and you need file storage now because we've created a Class A Separate class that handles storage in files yes storage in files anytime we are going to build any python projects that requires Sim all we need to do is to come and grab the code that we use for the class okay so it makes our code reusable it becomes way easy that is why we have put the file storage into a separate class but then how are they linked how am I going to link it so for instance inside my base model inside my base model I am going to create so inside this class I'm going to create a message called so let's create a method called save and what does this method do this method is responsible for saving an instance an instance of the class into the file so that's what is responsible for doing but then when I call it you and I know that what is actually going to handle the file storage is the file storage class that we've created that's what I'm saying that we could have done everything in here but then we've decided that all the instructions that we're giving were supposed to create the file storage class separately so what you are going to do is that inside the save model here you would have to call this file storage class so you have to make a call to it so that you save whatever you are passing through it so here we have self then because we've defined most of them as class attributes the class attributes will be passed through the self variable down here or even because the class attributes we can receive any sort of attributes down here okay so let's assume that for each of them we needed the attributes we needed the ID we needed created ads time we needed updated ads time so for those of you who don't know or who didn't know in order to do the time for they created out and updated that time we are going to use a model called a daytime model some of these things when you start working you don't know them of it it is you want to implement something go to Google Search I want to implement this in Python what should I do then they suggest a model for you go and search on the model invite you can even use the official python documentation to read on the model to know how this model is implemented for instance if you are using the daytime model how do I get the current dates okay so you go to Google and find out how to get the current date from the daytime model and you come and implement it to get the current date for creating or updating so if we call the save method of our base model we expect it to go and save the instance that we have created with these details or any extra details that we have passed through it provided it is being called by a Class A Surplus or a class that inherited from this parent class so to do that we would therefore have to call the safe method of these file storage okay that means that wherever you are implementing your base model you would have to import this class the file storage class so depending on where you store it maybe it is in a file called file storage browse storage Dot py okay so you don't have to bring py sorry so we could import it this way or there are several forms that we can import it so we could also do from this file storage I want to import I want to import file stories okay then you create an instance of this file storage in here and use it to do the storing but then with the implementation that we were given we created kind of a universal instance of our storage so that we can access it anywhere we are so when I come in here I know how to come and create an instance if I call it this way I'd have to come here and create an instance of it and say storage is equal to file storage like this create an instance like this then now I can go and call the method on this instance and I'll do storage dots save and pass self to it so that it picks the details here all the details here a passage to this storage to go and store it okay but in the current implementation what we did was that inside a given I'm I'm trying to be very careful so pardon me when I don't want to talk about things but then what we have right now inside a given file called underscore underscore in it underscore underscore py we were asked to create were asked to create an instance of the file model in there or instance of the file class in it so inside this scripts okay you'll find that you would have imported or say what I did here let me copy that you'd find out you have imported files to it and you have created an instance of that called storage is equal to file storage like this okay and the good thing is that anytime they application run like any module that is running within this package so for those of you who have learned more about I mean by now we should have all learned about it those in chord seven when we take a Model A model is basically a python script that we can import to use in a different location or in a different script okay so that is a model it's basically uh writing scripts that you can import and use in a different script so essentially almost any python script that you write can be used as a model provided it is imported and used in a different script it becomes a model automatically then a collection of these models in a given directory can be termed as a package so a package is basically a collection of models in uh giving directory then interestingly a packet should have this file another underscore in it so we say a magic file or the yes Magic file and that's when I was going in it uh understand underscore Dot py it should have this in there this file in there to show that this is the package inside this file you can put things that should run anytime the model any of the models inside this package is assessed does that make sense inside this what we have done here okay we know that this file all that is doing is making sure that that directory that contains our models is seen as a seen as a package but then inside it we are instantiating the file storage class for that matter anytime the model file storage model is used anyway this instance will be created and that means we will have access to it we can import storage directly so we don't necessarily have to go and import a file which is oh I didn't include the import here from file storage Imports so this time around we don't need to go and import this whole thing we need to just import our stories and once we import storage we can use it as if we imported the whole file okay so when I come here instead of writing storage is equal to this and creating the instance I'll just go ahead and call my storage.save method the save method on it and I will store the instance that has been created here is that making sense I hope it's a quick question sure go ahead quick question so are we saying that if I score an instance of my magic uh I saw an incense of a class in this particular case fast storage and uh in it or the magic file I don't have to import I know how to import uh what's it called the file storage into for instance I want to use it in the base model um it doesn't mean I don't have to import the file storage and then I can use it automatically without import ance what you're going to import is you're going to import the instance that you have created and not necessarily the class itself you get it sorry no I no I'm not getting it because my question is the instance of the of the class has been created and placed inside in it it's either in it in the magic file I understand that part now I want to use it so right now it's Global to all models in in which they're in it is right so it doesn't mean I don't have to like do that particular or I can I can use it without uh without importing from the file storage or whatever do you understand my question can you can you see my screen hello yes can you see my screen kwabena can you see my screen so you realize that over here I'm not importing the file storage class that I created I'm importing the instance that I've created because the instance is available for my use do you get it so if I haven't created the instance I would have to import the whole model then create an instance of the model anytime I want to use it but then to make things simple I've made it available because I'm going to use it widely so that I'll just import that specific one and not every one of them it'll probably we've lost him with network okay [Music] um where do we proceed to so essentially essentially when it comes to the storage part that is what we have done okay that's what we have done the basic implementation is just following the instructions that you've been given create this for uh this method create this other method this method should do this I don't want to get into the nitty-gritties I want to give a general overview and if we still have time we can then look at the basic basic stuff okay as in how you create the models and I mean the classes and the methods so now we have covered three parts the a two part sorry so we've covered the back end which is the op part then we've covered the storage Parts which are going to use the Json to help us store the data and why we do it the next thing is to cover the front end part the front end part is what we are calling is a control application so we have to look at how to implement a console application for I've gotten a few people reach out to me and they are like with their current knowledge with python they want to be able to build something meaningful and things okay and when I learned about the CMD model I was like okay this means that almost everything that you have learned you cannot use it to build console applications you just need to learn how to use this model to build a console application so let's pay particular attention to this after you are done with this project any of the programs that you write in Python you can convert easily converted to a console application that others can use it's not like user friendly obviously nobody wants to play with a black boss there's no user friendly and pretty soon we'll be learning how to write the front end using the web stack applications I mean using HTML CSS and things but then as we haven't yet gotten there the CNU model is one that will help you create something that is equally useful okay so basically what a CMD model is is and how to create your own console application or your own like like what we did with the shell application okay what we did we saw was we built our own cell that we could use it understood the commands that were given it and things so now we allowed this whole Airbnb back end uh with storage facing abilities but if you don't build it into the console application scene if you have not added a front end to it the problem is that no one will be able to use your program unless that person is actually a programmer a python developer so if I want to create uh something if I want to create a user with the back end that you have written I have to go into your code and write it out and say for instance if I want to create one I have to create an instance of say the user model so I'll say my user is equal to then I'll Now call the user class then my user dot maybe update so if you don't develop the front end of it this is the only way someone can use the code that you have written the person will have to understand oop I have to know which match you had in there to be able to create it and that is not a good thing I mean that's not something you want to show to anybody if the person is not a developer so this time around we won't say that when they run our program they are greeted with this command line interface and anything at all they want if they want to create a user they should just say create a user so we are building and a console that understands a certain set of commands so create user I am defining what create user should do so when somebody types create user on my console application is going to create a user for them they can come and say update user and pass the user ID they want to update so this user ID what do I want to update I want to update the user's first name so I could have something like this then say the first name should not be changed to orbit and my console will understand this compare this to what this person had to do this person had to come and say my user dot update then pass this information okay so the ID the all of these things in here but once we create the console application all they need to know about is the various commands so what commands available in my console so for this specific case we are supposed to create a command that can be used to create a command can be used to show a command that can be used to count a commander can be used to destroy that is delete and if you remember this is similar to what we're doing here create read update delete okay it's very similar some of them will require combination so create show count updates then we have a commander on lists what was that command like that okay I think so so do that okay yeah yes so let's take today's command so we are supposed to build our command line interpreter to be able to interpret all these commands when you say create you should know what to do when you say so if you know what to do when you say count if you know what you do when you say destroy it like that okay so how then do we build it how are we going to build it two things that you need to take note of to build this first you need to import Imports you need to import CMD it's a model available in Python itself so when you import CMD you have access to it then so it means that we are creating a file that we are going to use to launch it let's assume that I'm calling my file I create a file called Airbnb Dot py okay and make this file executable this means that anytime somebody wants to run this they have to execute it this way airbnb.py then when they call inside this file I want to make sure that the command line will only run when the file is called by its name and not when it is imported as a model remember when I was explaining the model I said any python file at all is a model provided it is imported into another script so we want to prevent it from executing when it is imported as a model it should only be called I mean it should should only be executed when it is called by its name so we use the command if name I hope I haven't forgotten this if name is equal to Main yes so if name is equal to Main what this means is that I am checking that did they call me by my name my main name or did they import me if they imported me I'm not going to execute so if they called me then I'm going to execute but after you have called this CMD for I left something out which I should mention you need to create a class that will inherit the CMD class from this model so let's create class called my console okay and this class will inherit from CMD dot c m no I think it's CMD let me confirm that I don't really remember this okay so it is dots it's only the C that is a capital letter so you call it like this you create a class class my console then cmd.cmd once you've called this class it's going to inherit everything from the CMD class and you can now go ahead and use all its features so in here I would say uh oh sorry let me confirm that this thing that's this is actually my first time working with it so yes the CMD Loop that's what I was looking for so we need something of this sorts to call it C even this is supposed to be underscore underscore name with them let me copy this to show you that and you don't need to memorize all of these things okay the more you work with them they speak if you don't work with them often the very moments that you need to work with them you just go and grab them or what's happening I tried pasting and it's not responding why okay did you know okay so so here my class writer is called my console my console yes dot CMD so this line has to be at the bottom of your script and all that it does is that make sure that you only execute this script when it is called This way everything is imported don't execute this code okay so that is the first few things that you need to do as soon as you start import this create a class so you can put a path inside here to not have an issue maybe I should this one I think I can write the code for it so let's let's create one save this as um B and B dot pi okay airbnb.py so what I said is that first you should import import CMD then after importing CMB create a class a class called so we said my sorry my console my console then let it inherit from CMD a class called CMD then I can write pass in order to not cause any error then I'm going to check if it is called by name is equal to underscore underscore mean and that's quite a score this and if it is equal to that that is only when I will execute the CMD Loop okay so for those of you who did the cell project for those of you who think they sell projects one thing you remember is that we had to create a loop for the show okay so that it is constantly in a loop showing a prompt for somebody to enter something execute after execution it shows the prompt so this CMD Loop method of the CMD class is what is responsible for that so if you ignore this your program is not going to run the way you want it to run this is what will ensure that at every point in time there is a prompt for a user to enter something and after they've entered it it will bring up a new prompt all right by default when we run this program I I believe it should work let me play and make this executable CMD mode plus add BMB okay clear ideas then so now let's run Airbnb okay expected to gain import command nodes found ERS error and here expected to keep this class my console what's happening oh what is this thing doing good yeah good day [Music] could you try adding parentheses after my console come again all right sure thank you all right we're still having the same issue let me let me quickly look at what I did here what different than Imports and then why is it not working look could you please zoom in a little I'm having a hard time seeing it because I'm using my mobile [Music] okay so let me let me try zoom in zoom zoom zoom zoom zoom all right there's no preference yeah does Control Plus work for you right to zoom I think I'm trying but it wasn't giving me an outcome uh it's not working you can go to settings oh okay okay yeah it's fine thank you sir okay you're welcome oh interesting Our Life Starts a programming I forget to even add this oh man hey this one too look scattered in front of me like I'm struggling to find my place here and okay so let's run it again hopefully this time around okay so how did I hey what so basically the reason it wasn't working was I wasn't I I ideally it could have even worked without this but then I would have called it with uh how do you call it python three four mentioning the name so what I wanted to show you is the default implementation this is the prompt The Prompt is called CMD so we can change the prompts with an attribute of that class called prompts so what it means is that if you go and check this CMD class inside the CMD model that has been created there is a class attribute called prompts and that is what is set to this so if I set it to anything else say uh please say this okay or maybe this then it means that when I run this code when I run this code again you see my prompts but then you can't do any of these if you don't know about the CMD model so we'll have to go and read on the CMD model to appreciate hey good hey okay sorry and so did all my other screen I ended up opening the internet so I thought it was really anyway uh I want to bring up a okay let me bring this up all right uh so there is there is a site called python model of the week yes button model of the week.com that is an abbreviation p-y-m-o-tw.com slash three slash CMD that's where I learned about the model so for those of you who are interested you can go read about that model from there the site is this you didn't copy uh where are you okay the site is this great so it's py represented python then model of the week.com yeah make sure you choose the three not the python to trade and CMD so when you go there you get the details about the available methods and things but one important thing that we need to know is that for this particular implementation the methods that begin with the word do underscore are commands that can be executed so if I create a method say do pld if I create a method like this let me go into the console let's do that uh bring this down okay forget this let's create a method called do remember all the methods that have do underscore pretending them they are commands that you can issue when you run your console so do underscore pld whatever I want it to do then you pass some off you pass off and another thing you could call it anything Alex but mostly lying for the line that was red then when this is brought in what will you do so I can say prints we are having a p l d what this means is that if I close this and run it again run it again then I do pld remember I didn't use do underscore pld it has been implemented that the command that people will type here is the same as the method that begins with dual score that command name so if I go ahead and run this it says we are having a pod so I've basically created a command that's done something and all that you need to do is to add it to this so if you need to create a command that says create and it should do something we create let's say that for this command if I say create it should print I have created whatever you give me okay so if I say create C I have created what did you pass to me uh maybe you pass whatever you passed okay so I save this I need to rerun this program clear this okay run it again now create what do I want to create a book so create book and it says I have created book okay so at the end of the day anything that a person passes you are now going to implement it and remember that when it comes to the current work that we are working on we have built a backbone somewhere that does all the things so all that we need is to call an instance and call a method on the instance and it will go and Trigger that action that we want to take place so for now you just need to know how the CMD model works and how to use it and that is what I'm showing you so I have everything that they pass what happens is that the first thing that they write here becomes the name of the method then the next thing be right every other thing they write here will be passed in as a string inside line so if I close this I shouldn't even have closed it and run it again if I run this and I say create then uh this is my story and I enter this it says I've created this is my story so every other thing after this after the method that you created okay what I will call the command after the command that you have will be passed as a string here in this argument and this argument can be called anything so I can call it um asks okay Acts like anything you want to be where the I think the first results I I started reading they were using lines so I start to use a line okay so that's basically how to go about it this means we can create as many methods as possible yeah however some if I go ahead and I use a create dot something okay so this is actually giving me because expecting all of this but I want to uh show something when we don't have creates okay so the example that we have from the projects we are dealing with is instead of saying create something I'll say book then dot create something like this and it's unknown centers dot create so by if default this program has not been the CMD model has not been configured to understand this but then your current implementation you need it to understand something like this so there are some methods class methods that we have to go and overwrite and when we are able to overwrite that one we'll be able to use our program as such okay so let's take a look at some of those class methods that we may need to override I'm actually not I understood all of them yet because I haven't tested all of them and I've seen the resource with you so you can equally go and read on them so some of the classes down here yes so overriding Base Class methods so some of these Base Class method you can override the stmd look to do whatever you want to do when we are done with a project you can come around I mean you can start your own console program and play around with all of these things to know exactly what each of them does so that you appreciate the CMD model and you'll be able to use it anytime you want so there is CMD Loop that can be overrated there is pre-loop post-loop pass line one CMD empty line default pressing the anything so personally when I wanted to see how to override it you read on they tell you some of them that is not recommended to override some that is recommended to override and things so I just took one of them for instance here it says each iteration through CMD Loop course one CMD this method to dispatch the commands it's Handler so the first time I read this I was like okay let me go and try one CMD out because he says that each iteration through it that means anytime I enter something on the prompts that's going to be an iteration through the program so it's iteration this method is what will dispatch the command to its Handler so it means I can intercept this method okay so let me override it intercept what was passed from the command line do whatever I want to do it to it before I let it dispatch it to the Handler so that could easily be done but then along the line too I am reading that is not the best for that I mean it's not the best thing to override this particular one even though in my initial implementation that was what I used the actual input line is passed with pass line to create a triple containing a command so those of you who did the simple shell project you remember that after we have taken the we have read the line from the uh so we are going to pass it into Strings okay in this particular case we are passing it into a triple then the rest who to create a tuple containing a command and the remaining portion of the line if the line is empty then empty line is called so this method will be called if the line is empty the default implementation runs the previous command again that's the default implementation of empty line it runs the previous command again okay so if I say that when there is an empty line there's nothing there is empty and I hit enter I want you to do something that means that you have to override this particular method because by default this method implements what the previous command then if the line contains a command first create CMD method is called then Handler is looked up and invoked so see what is happening when let's let's go back to our board what is happening here is that when the loop is set in place okay CMD Loop is called when it's set in place the next thing that happens is one CMD but when you look critically there are a number of things that actually happened before this uh one CMD in fact there is pretty low post Loop and things I think Prelude should come before one CMD I haven't actually at least 12 so I can't mean that finally but then the basic logic that I've gotten from what we just read is when the loop is started when you start the loop we pass whatever was put inside the command line okay it's past year so let's say it's passed as time then this cm1 CMD will pass it through what we call past line then pass line will break line into a token a token of so it's going to give us okay let me write them below them so this will give us will pass line to pass line pass line will break line into a token of command and the rest of the line so we have something like this from past line then pass line will check what did they say there [Music] um says and the remaining portion if the line is empty so it checks if the line is empty if it is empty then it will call this if it is not empty then it calls press CMD so the next thing is spray CMD so we have this passing grade CMD passing the information to pray CMD then why would president MD is what is going to check let's go back where is CMD call then the Handler is looked up so crazy MD will look for the Handler for this particular command that we have created and invoke the Handler if none is found it will call defaults okay and before when you read about defaults the one that retains the error messages so basically what is going to happen is that race CMD is now going to take the command and check does this command exist if the command exists is going to invoke invoke the command but remember that the command so it's going to invoke the command but remember that the command is implemented this way do underscore command that's the name of the command then it will pass that line that pass line gave it as an argument to this command or this method okay and if this command that was given to it he didn't find any uh any message so let me see if I didn't find any method that is going to use to invoke a it will now pass the outcome to default and default will unless you have overrated default it will throw the arrow doesn't make sense so now we can intercept this loop at any point and overwrite what each of them does I started by trying to override this it was giving me a few issues even though I was able to do it but then I feel probably that is not the best thing to do it is until we have played with it very much that we will know exactly which one works best so for now I'm thinking of intercepting this okay so how do I do that when I come into my code I just have to write a method called so I create a method called Break CMD and let's create CMD will obviously be receiving self and line okay and when it receives line what do I want to do with lying the default implementation is for you to return it will return cmd.cmg no it's pretty CMD with line so this is the default implementation okay this is the default implementation so what it means is that now I haven't changed anything so I can go ahead let's start the program again run this and if I say create book again it's going to give me oh what is there so I think cm to take only line I guess so let's run it again create book hey it's one position argument that's two were given how did I get through let me confirm that so I should have even looked at the example they did over there but then it doesn't spoil anything uh uh CMD CMD where did I write here one CMD one CMD because I've zoomed into this thing uh okay so it takes it takes those two yeah why are we having the air self then this only the default implementation I'm not doing it right let me click oh so it should take the self as well okay okay okay this is I didn't even pay attention to something because the error message would have told me the line that the error was happening all right so I expect that now even though I've written a method praise CMD I haven't changed anything the default implementation for that matter I expect that everything will wear as if I don't have that method today okay so when we run it and I say create book it says I've created a book okay now let's see something if I come in here and I set line to be equal to see shoes let's exit this program run again then now call creates book oh so the thing is first of all we need to understand how lying comes line comes in uh was it so relax let me print how lion comes in here first so that we know exactly how to override line line comes in here Airbnb creates book okay so this is how line is coming in it's made up of two things okay so what we can do to override it now that we know it's going to come in this form what you can do two variety line let me split it into two command and command and let's say add is equal to line dot splits so I'm splitting at where there is a space and splitting out where there is a space now I want to build a new line and see line is equal to f g [Music] um let's use an F string build a new line command followed by then I want to type shoes let me do something like this and see so some of these things you have to be playing with them to understand or sorry I appreciate how they work creates book you see I type in create book that is now giving me I've created shoes only because I have changed this to shoes I've changed the line in here okay so what it means is that when you are calling this format uh say user dot create this format and it's giving sorry it's because of this line that's why he gave me that Arrow something like that let's run the program again we said what user dot creates like this okay and it's giving you unknown centers now you have to go in there and find out when you pass it how does it actually pass the command okay so you realize that here we are printing line and this is line that was printed it's renting it at user dot create but you know that that is not the format that we want line to be we want line when we call user.create we actually mean we want it to become create user do you see that this is what we want so then we have to work on our line to get it into this format so first of all you have to set in a number of conditioners to check because people can use different ways in fact the easiest way which I started with but then I realized it wasn't robust enough is to check if there is a dot inside the line that is passed if Dots in line if that's in line then I want to do something I want to change how line comes if there is no dot then go ahead and use the default implementation okay just like the easiest thing I mean like the easiest way you would have thought about it in the first place but then later when you look at edge cases somebody creating or dating email and things you realize that wouldn't work okay so for now let's let's assume that that's what we want to achieve like to help us get what we want to do so if there is a line a dot in there we are assuming that the person is using it this way instead of saying create what do we want to do we want to split these two we want to split it so let's see or we could we could use replace I think replace would be easier so what we can do is to call replace online and say line dot replace what are we replacing in line we want to replace we want to replace the dots with what with a space with an empty space so by doing this by doing that what will happen is that our line will not come there then space creates then we still have the brackets okay so I want to also replace these brackets I want to replace this black bracket I can do it in multiple ways but the nice thing about writing objects is that you can continue to use the dot notation so dot replace what am I replacing the opening bracket what am I replacing it with I'm replacing it with an empty string so nothing in here then when I'm done that we want to replace the subsequent one two so I can call another release this is not like the best way for those of you who have mastered uh regular expressions the best way will probably be using regular expressions okay but then for now just so we may achieve the purpose we are looking for oh Europe we should stop uh I want to replace this with nothing okay so let's see let me just intentionally run it even though it may still end up giving us an error uh just to see what our line is right now when we call it diary so when we call it as user dot creates what do we have oh it didn't do this then replace foreign what's happening keep this in line oh sorry I need to reassign line okay so I needed to reassign line I forgot that let's run it again and see user dot creates run this and you see now we've been able to remove the full stop we've been able to remove the parentheses in front of it so all that we need to do is to split this into true and change their positions okay if I split this into two obtain their position I know how to create user and the quote originally understands create user so you will go and execute it for me so I'll just come here and say uh I'm going to spread I'm going to split this by line into two let me see the easiest way to do it uh so a call line just so I'll make it clear for you to see let me say command okay oh no uh lying let me still use line it's going to create a tuple of the line line is equal to line dot splits and where are we splitting we are splitting at where there is a space okay then we are going to print line again just to see how it's going to be presented I am looking forward to seeing it in a triple or at least one of them a triple or a list okay so if we say user dot creates user.creates we run it okay it's giving us a list it's giving us a list so we have user and create once we have this list we can do something about the list change their position and form a new uh words from a new line so line is equal to our F string let's use x string to build our line the first one is line at index one remember sorry I have to put it in curly braces yes remember that line at index one is create and line at in the zero is the user so we are building a new line we are saying this at in the zero oh why did I keep you here okay so what's this yeah great so now that we have this let's go ahead and execute our code if you have any questions just post me and ask the question I know it's becoming a lot right now but then if you take your time and go through it you will pick it so let's call user.creates then pass this and he says I've created a user so now our code responds to create user it responds to user dot a yes user.creates in this form and that's only because we over roots or we change the default implementation of pre-cmd okay so if you also are interested in changing the default implementation of Praise MD then try playing around race CMD play around it see exactly how it works and this is how you learn how it works you print each of them that you receive you're going to see what is the outcome okay I want to change it to this format so what should I do okay so now the last bit that is a bit tricky which I want to show then open the floor for questions is that if you want people to be able to run your program from the console that through piping I mean from this terminal I should be able to run give the programming code so I say Echo creates user then I pipe it through your program Airbnb sorry then I run it you see what he's doing to me right now so it is not working how do I get that to work that's what we want to look at next how do I get to the website that when you call it that way the program is able to work it's simple actually what we need to know about is the difference between how will I say this whether whether the um output is coming from whether it's coming from standard inputs or it's coming from the camera Okay so let's let me just go ahead there is a simple command that we can use in writing and let's implement okay so that's basic command let me paste it here so that you all can see and maybe when I share the PDF you can have access to it so to make the app work non-interactively all that you have to do is to check if the system dot system in is not a terminal okay if it is not a terminal that means that it's being passed through interactively if there is no check like this by default your system will always go and check from the inputs from an input device like the keyboard okay so just by bringing this inside your press CMD all that you are doing is that you should always check when the call the program is run if you first check if there is something like you're checking if there's been a command but it's not coming from your keyboard it is not coming from your keyboard I just said print an empty space then give me the rest like go ahead and do the work okay so all I need to do is to add this to my code somewhere inside my code where do we have the CMD here okay so let's put it up here let's put it up here we need to import the sys model so for it to work so come here and import s this after importance is now I should be able to run the code the way that I did earlier oh what is wrong create user I don't know why this is not working creates user [Music] will get passed to this Airbnb and that should work why is it not working foreign but basically that's all that you need to do for it to respond um run it again foreign let me just confirm what I did uh did I do anything different oh my goodness so I have to take time to figure it out I don't know why it's behaving this way but ideally you just need to add that line of code and it should work I still don't understand why it's not working because I am echoing this creates user then I'm piping it and piping it to Airbnb all right so let me leave it here take your questions I'll share the PDF with you so that you have that snippet of code yes questions if you have questions so basically I Illustrated this thing it works I don't know why it's working yes any questions so far okay um so I checked I checked um in Chinese now and I think there is a space between the piping I don't know what if that's why it's not working oh I left space initially it wasn't working okay I really don't know that thing that's because this morning my own code is even running and it's the same implementation in my own code I'll figure it out if if there is any prominent thing I'll let you all know via their group I'll say it in a group yes any other question okay quick question um I'm struggling to hear you can you hear me now yes okay go ahead okay cool cool so my question has to do with can you um wow I I can hear you like it's going down and down and down but when I showed you my screen yeah yeah you know when I showed you my screen did you see it thank you so much so the next my other question has to do with um we were my partner my partner and I and and some others were working on the what's it called the file storage and we got to the reload you know where you are be serializing I mean from uh I mean basically from the file then you just realized so I can still in there and you can't store in there you can store in a class okay the private class exactly and um essentially it's supposed to be the reverse but I found out after you have um read from the file uh into the into json.loos then it starts giving you this uh these are Json dots decoder Jason something oh okay for some reason for some reason it's not able to I don't know it seems like I we need to do something extra for it to for you to convert from the Json formatted string into the into the dict class you know before you can send it and uh I don't know if you could help out to help help help me out with I mean okay behind it what what is missing I don't know yeah thank you okay all right that's fine so I I actually feel your pain the reason I say so is that I had a similar issue and my partner can bear me witness that that will load Parts took us a very long time I built it initially was working then after some time I think when I got into that was a wrong tax fight it was giving me the right outcome I went through to like outside tax I or so and I realized now that tax five the representation is wrong right I thought this thing was working so I came back to it to come and check I checked everything like everything I've done I think that is it but then I'm still having the same issue but previously it was working too so what has changed what has changed I didn't know so I went to the extent of going to regret my code back to the commits before that because unfortunately when I did tax five I didn't commit my code I only committed it after tax six and when I reverted to the comments after taxes it was still giving me the same error so I had to revert back to text uh three and four commits then build it from there and I ended up getting the same error so it was quite tough that's why I'm saying that I understand what you are saying but then I don't really remember the exact then that's changed the whole thing so here this is the nasty thing I did to solve this problem so basically we we are trying to create put everything into a dictionary then pass it to the objects that we have created so that when they print it out it will print the string representation of that object okay because you realize that if you don't do it right is going to print out just the dictionary that you created so it was a bit tough here I called the object dictionary that has been loaded so I'm saying that when you load the data I explained already with the help of json.load when you load data from a Json file python with the help of json.loads will automatically convert it to a python dictionary object so I'm going into this dictionary object and I am picking the key and a value but then this particular design object appears in this format the key is the ID does the classname.id if only you have implemented it you understand those of you who haven't implemented it yet when you are doing you would you would appreciate it then the other part is also a dictionary so I know I need to grab the class name coming in I'm saying it's like a dictionary I need to grab the class name I mean I'm sorry like I'm struggling to hear you again sorry sorry is it can you hear me now hello can you hear me now no I'm struggling can you hear me now okay I could hear that okay okay cool um I've seen um what what were you saying uh saying so first and foremost you have to obviously read the file right I'm I'm just I'm just I want I just want to go yes yes right you first have to do that yes and and basically the the contents is a Json formatted string I mean it's a class string yes yes okay then from there picky from there that's that's what that's where I got stuck that's right so after after you've loaded it it comes in through this like you've created a python object okay so just say it as an object this object happens to be in the form of a dictionary so you need to go inside it the way that I figured it out was first to print this object and see how it actually came exactly exactly so that once I know how the object looks like I know okay what do I want to do with this object okay so I realized that in that specific object you have the ID which is like the base model dot something or user dot something then I mean user Dot and I then a dictionary that contains the details about that giving instance so I walk in there and there is an attribute inside this particular dictionary that we added when we were serializing code underscore underscore class and that gives you the name of that class so I quickly picked the name of the class there it may not be necessary but in my case it was necessary because I was going to use the name of the class to do something okay okay so what was I going to use the name of the class to do I was going to call the name of the class here we're assigning this so remember I created an empty dictionary here that I'm trying to use to go and put the details in so this I'm giving key ID here and on to generate that hmm uh you know we have we have implemented a class already go in here this one okay let me see let me show you how I came by this okay okay at the end of the day I wanted to achieve something like this I wanted to achieve something like this final underscore dicks that's the dictionary that I'm creating yeah the the key will be the ID then the value of this this night is going to be something like this model then I'll pass a dictionary to this model okay I'll pass a dictionary to this model and when you go back to your implementation of the base model class as yeah you realize that inside the init class we checked if they pass the ID then unpack it yeah okay to create the instance so basically I just needed that init core on a class but then it could be of it could be any class at all it could be a user class it could be a base model class it could be any of the classes so it was a bit dicey over there power storage here so I couldn't just have called this model like that and even though I know the name of the class I've picked it today okay the name of the class if I put it here or even if I evaluate it and put it here and inside that was what I was doing I was evaluating this so I'll do something like Eva then I'll pass the class name to it that should ideally work but then it retains this as a string and the next problem is that if you are calling it this way you need to have imported base model that means that I have to import every of the models that I'm going to be creating no sorry every other classes that I'm going to be creating inside this file storage have to be important then to have access to each of them like that okay so to work around it smartly I decided not to import them directly but create a class sorry create a method that our core classes and inside that method I will import all of them so that import will only take place when something is called okay because I was getting an error when I was trying to call them individually I was getting an error that said something about circular importation of the model okay so to revert that problem I came into this and created a class created a class called classes and inside these classes I am importing all of the art classes that I've created from models then I created a dictionary that will retain each of the class that I've imported for me so basically all that I've done with this line of code here this line of code down here self dot classes remember that classes is a method that I created that retains a dictionary so this is essentially retaining a dictionary of all my classes that I have and I am passing the key class name so if this specific class that we have got in the instance that we have gotten is from class base model the key here is base model so at the end of the day I'm going into this dictionary which is here this dictionary over here okay I'm coming into this dictionary and I'm looking for the key base model and this key based model will retain the class based model you see so essentially I end up with this model here and I have passed the dictionary to base model that's all that's what I did here then now I reassign the file storage uh private I think it was a private attribute to the final objects so that anywhere it is being used and being printed we are getting the actual update Details In The Stream representation of it I don't know if that makes sense I know if you haven't done it it wouldn't make sense and myself if I am to just look at it like this it will still make sense to me but then it's because I walked through it I had a problem try figuring it out the the nice thing about programming debugging your code teaches you a whole lot of things okay so the best thing you do is try printing at each step like how showing when I was doing the console model thing each step if if you've not figured it out just print that thing and see what the outcome is and see is it what I'm looking for what can I do about this then you continue like that I hope that is helpful um okay can you please can you hear me yes I can hear you okay good so um trying to follow honestly I'm trying to follow because um basically what we were doing was that um because we were told I mean python as a circle I think the voice is going now again okay sorry and yes I speak allows you that the others too can hear the others who can hear oh sure I'll try to maintain the same volume and so basically what we're doing was um because the set python as a circle is similar I mean we go in there try to understand the concepts because pattern as a circle broke it down you know they broke it down so we were I mean that's how we use that's that's what we did to figure out I was actually doing same too exactly so that's what we did to figure out the save and it was very it became very clear but so what we'll do is at each point in breaking down the process because say for instance there's like about two or three processes before the voice is gone again sorry save for instance has about two or three processes before you can even save into the farm so I got here I hope I'm not the only one or is it from my end and essentially when we go we can't hear him yes it's difficult to hear what you're saying we can't hear you wow we still we are struggling to hear you frankly I don't think I can hear you as well just keep talking can you hear me hi kwabena hi yeah so it looks like he cannot hear me we can't hear you hi kwabena we can't hear you we can't hear you nothing it's still two things any other person has a question to kindly bring it up we are about to close we've passed through our smile yes yeah so I I was saying when after you have passed after you have read from your Jason file it seems it's it's a string and I tried using the json.loads to convert it into a dictionary but it wouldn't why not I don't know because you did you see how I implemented it here yeah okay as soon as I got the Json dots loads to pick the file that I've picked read it from it it is an object okay so now that is why I could come and do for ID and dictionary in this dot items this wouldn't happen if it was a string that's fine I'll I'll try and Implement again and I'll just give you feedback all right so we are in the group so anytime you need help you can always Reach Out any any other person any question thank you welcome hello hi hi concerning the private attributes five parts okay are we just passed Define name or we are going to pass the um the full parts to the five partnership oh yes I think given the question made it clear I it's it's a shrink so just write the string there when it will look at what you have written there to create it so every pass uh I haven't tried with an absolute path but I'm sure if you pass an absolute path it will go and create it in the location that you pass it so every passage just it will create file.json in there for you so I believe that's how it's supposed to be done uh okay which means if I want to create the file in another place that's when I should um specify the absolute part right exactly exactly that's what I believe I haven't tried it before but I believe that should work so when I said Json does file it's automatically creates the json.file here uh where is it file.json sorry did I say Jason Alpha so these are the examples I've been dealing with okay Json file is not easy to read when you have it in the data like that okay so for those of you who'll be testing out your course to see whether it's working or not there are a lot of Json formatters online so just go online search for Json formata click any of them and paste the adjacent code that you had in there when you paste it in there it will format it in a way that makes sense I mean easier to see so after you update something see there's an example that I've been doing and if let me place the new one I just copied in here so this is after it has beautified it for you so now you can see that this is one data or one instance in our case this is one instance and this belongs to the base model class this is the ID is created at this uh the attributes this that's that this is user instance so at the end of the day when you are implementing your account function you can come and see okay how many user models do I have here one two there are two of them then you can check if they are really two of them okay so make good use of these tools any other question uh doctor sorry I have a question hi the question is the code uh based question I noticed some uh double aesthetic in your code like what are they supposed to do for their dictionary okay okay what keyword arguments exactly you don't have to specify that for you to go in that way all right thanks yeah so this is what he was referring to yes yes so I mean if if you want to format your Json file there there are I mean in vs code for instance I mean there's a Json formatter speak up in store I think it's mine I'm saying if you want to format your Json file into Json there's there's an in I mean like you can either install a Json format or use PTR code and vs code is simply a matter of selecting it and and when you right click okay um format format selection with and you can try it right now yeah okay yes all right thank you for sharing that I didn't know thank you so much okay so that is good so now you don't need to go and use the online formatters you format it in here except for those who are still using VI hi hi to all of you I salute all of you everyone has a plugin that can do this for you as well okay that that's why I'm saluting you people because you people are one of them please thank you okay uh you're also running are we I mean I'm a nano person I don't like them thank you hey you're a No-No person so I salute you too yes any other question otherwise I think we'll bring our session to it and any questions I'd have loved to do more that more can learn me in problems so I hope this is yes I hope this is good enough [Music] the PDF yes I'm sending a PDF and hopefully by tomorrow morning the video will be available on YouTube as well okay okay yeah great maybe maybe sometime in the future we'll get to in fact Let me let me let me give this word of advice this is a very big project to me I like this project compared to all the others that we have built okay because this is like something unique why do I say this way we can use the same Concepts we've used here to build an application for ourselves so try and understand there's feedback coming from someone you're all muted I don't know if it is coming from your side but there is feedback from yes so you are the only one muted Sana kindly mute yourself oh okay let me mute sorry about it yeah so um what I was saying was that after this project the experience that you get you can actually use let me move away from this man you can actually use the experience you get from this project to build your own projects it could be anything now you know how to use the CMD so if you want to build a calculator you can build a calculator that works via CMD if you want to build the back end of your website you can build that and pretty soon I think from next week we are learning SQL to look at how we would attach a database to this code that we have written instead of going to the Json file Json file managing Json file is not easy managing it when we have it in SQL I mean we have it in a database file it's much easier and therefore we'll learn that and we upgrade okay so we are going to build on this project so we've built a full clone of Airbnb and my time you've built the full clone of Airbnb we can say that your full stack developer or engineer for that matter because you have tackled every aspect now we've looked at the database yeah sorry go ahead yeah okay so and this is the first project that we are building that you can actually show people right exactly you couldn't show anybody to anybody else the question they ask you is why why why did you have to recreate printf because it's already as if nobody is going to use your printf no way you get even yourself like why will I leave bus and come and use yourself so those ones were for learning purposes but then this is like a practical uh a practical project okay and you're going for job interviews these are the type of projects that you can show with my knowledge in Python I've built this I built an Airbnb clone the back end of an Airbnb clone and interface it with a console application this is it and maybe by that time you would have done your SQL part but if you haven't done your SQL part having knowledge of working with file storage 2 is excellent so you worked with power storage you have that knowledge as well you can say that but then let's not only rely on this project because the issue about relying on this project is that a lot of people have done it a lot of people have done it it's available on GitHub so how should am I that you didn't go and copy the same code and present to me if let's say you're looking for a job and the only project that you can point to is this particular project that is in your GitHub account as you admire that you didn't copy it from somewhere unless if I I want you to walk me through it and you can easily walk me through it but then people won't usually have that thing so out of the knowledge that we get from here let's try and make something unique it could be very simple it could be the same model base model the same class don't call it Airbnb call it anything your your own hotel websites that you are building loaded back to GitHub you created your own Hotel website people could book rooms people could create accounts in your hotel and things then eventually when we start doing the front end part two you know with something like that into it you've built your own hotel application can't even end up selling it to a hotel if you love money like some of us do anyway thank you so much for joining I appreciate your time being with us hopefully next week we'll resume our pods and we'll have to learn about exceptions hey I didn't talk about testing I didn't talk about testing so testing is a very important thing please and please and please again go and learn on uh learn on unit test model let me quickly invest it in a PDF so that you can have access to it uh where did I write this okay sure it's it's not I mean it's not a lot but and some of you know it already except that uh it may be a reference meant for some of you as well so testing go here uh say testing with units tests model then let me paste this okay so I'll share it with it there's not a lot as I said but then it may give you some information probably you know it already and okay so let's learn about testing recently I watched an interview on YouTube I think it's again that was being interviewed and he has been working with Amazon for hey sorry Microsoft for the past three years and what I heard was that as a software engineer he works in a testing department so all they do they are doing activities yes building tests for the developer apps that Microsoft produces okay so it means that this is equally important you could be employed as a software engineer that is involved in testing we have different types of testing there are some testing that is not for software Engineers but at least you need test is for software Engineers integration test as a software engineer you may be involved in it and some of us no let me know see some of us okay us all of us I mean some of us may be interested in working in startups and for that matter you would have to be doing most of these things yourself if you want to also become a Founder build your own company like I want to do you would be able you should be able to do all of these things by yourself especially if you are going to be managing people you should be aware so that when your subordinates are making mistakes can direct them thank you all for being here and I'll see you in our next session bye next session
Info
Channel: Dr. Ehoneah Obed
Views: 28,786
Rating: undefined out of 5
Keywords: airbnb clone alx, airbnb clone holberton, airbnb clone console, airbnb clone with python, airbnb python console app, AirBnB clone - The console, python cmd module, python cmd commands, console application in python, console app python, airbnb, programming, coding, alx africa, alx project, alx pld, alx peers, holberton school, holberton school alx, ehoneah, ehoneah obed, airbnb holberton, json file storage python, python, json, cmd, console, python oop project, oop, oop programming
Id: P1cNeo-0ioM
Channel Id: undefined
Length: 140min 46sec (8446 seconds)
Published: Sat Oct 29 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.