Current location: Homepage > swift > Generative AI Full Course – Gemini Pro, OpenAI, Llama, Langchain, Pinecone, Vector Databases & More - Ep203

Generative AI Full Course – Gemini Pro, OpenAI, Llama, Langchain, Pinecone, Vector Databases & More - Ep203

2025-07-11 11:40:06 [news] Source: ByteGenius
not o dopath uh doexist this filepath okay this file path that means thefile path actually I'm having so if itis doesn't exist okay in my directory sowhat I need to do philosophy of aiokay I need to createit but instead of using one particularlogic I'll be using another particularlogic I will also check the size of thefile so what I can doI can write another logic here soW uh dotpath dot uh there is a parameter youwill get called G size if you want tocheck uh any particular size of any anyfile so you can use this method actuallyget size now inside get size you need togive the filename file name and that uh if it is notlet's say uh if it is not let's say uhequal equal zero that means if this fileis not empty so what I need to do I needto create that particular file so forthis I'll just use withopen with open and here I will give myfilepath okay and here I just need to createit so that's why I need to open withwrite mode okay once it is done I'lljust do the pass operation here becauseI'm not doing anything I'm just onlycreating that particular file here okaythen I also need to log the informationso what I can do here I I'll just writelogin login.info login. info and here I will givethe log so I can just writecreating creating emptyfile and let's give the file namehere file pathyeah and if it is already exist so whatI will do I'll just writeelse so I'll just give the log messagehere so login doinfo um here I can give uh this filefilename isalready um created okay so this is themessage I think I can give yeah so thisis the simple I have written so guysthis code is understandable for you yesor no give me a confirmation in the chatare you getting this code how I havewritten it's a simple python codeonlyyes okay great now let's execute thisparticular template file and see whathappens okay now if you see left handside I I don't have these are the filesand folder okay now once I will executethis template. Pi let's see what willhappen so I'll open my terminal I'llexit from mypython uh first of all let me uhactivate my environment I'll just writecondactivate Mchatbot now let's execute this template.Pi so template. Pi see see the magicguys automatically all the files andfolder would be created left hand sidejust see left hand side and see the logguys it is saving my Tim stamp thecurrent time stamp I'm executing thecode as well as the date and it isgiving you the message like directorycreated SRC for the file of uncore uhinit.pyagain creating an empty file inside SRCuncore init.py okay that's how all thefile and folder has been created and seeleft hand side guys we are able tocreate our folderstructure uh in just oneshot okay now let's see you need someother files and folder okay in future sowhat you need to do you just need togive the list here let's say I needsomething called test. Pi I'll just givetest. Pi here I'll save this one againif I execute the same template. Pi uhokay so it istelling this system cannot find thespecific Pi okay I'm getting one errorlet me see test. Pi has been cre ornot okay static it is throwing the errorokay static should not be empty so hereI can giveuh uhCSS or I can give U just dogitignoredogitkeep let me remove this static filehere now let me execute itagain okay it's throwing error just aminuteum file name Stsize not o. get software line five getsize return file not found the systemcannot find the filespecified underscore uncore unit.Pi maybe my logic iscorrect okay now it's done I think yeahnow if you see uh my static folder hasbeen also created now here ifI uh just uncomment this test. PI rightnow and if I again executeit see guys it has created okay now seeyou can create as much as file andfolder okay it's up toyou okay so in this case I don't needthis test. Pi I'll just remove it andhere I will also remove the test.py fromhere all right so in future let's say ifyou're developing any kinds of projectsinstead of creating the folders and filemanually what you can do you can createthis particular template file and herejust write the logic okay it would beone time effort but this file you canuse it okay in your every projects justuh execute this particular file and itwill automatically create the folderstructure foryou all right now let me move thattrials file in my resarch folder so I'lljust move it I'll just cut it in myresarchfolderyeah uh everything is done now let mejust comment the changes in my GitHubquickly folderstructure additso guys so far everything isclear you can let me know in thechat like how we have created the folderinstuction and all so far everything isclearokayokay fine now we are done with our uhproject template creation so now secondthing I just need to write my setup. Pifile okay why I needed setup. Pi filebecause as you can see now we havecreated so many file inside the folderokay now let's say I want to importsomething from this particular filelet's say help .p I have writtensomething now let's say I want to importthat thing inside my app.py okay so whatI need to do I need to write from SRC dohelper import something okay so if youwant to do this kinds of operation thenyou need to set up this particular SRCfile as my localpackage I think you already familiarwith what is local package okay inPython let's say whenever you installany kinds of like package from the piywebsite okay it is already hosted on thepii website but uh it can be also donewe can also create our local package aswell okay let's say here if I do uh peplistpip list so it will list down all of thepackage actually I have installed inthis projects okay but here if you seethis SRC is missing okay SRC is missingso if

(Editor: web3)

Recommended articles
Hot reading