PACKAGES: ======== COLLECTION OF MODULES IS CALLED AS "PACKAGE". PYCHARM ==> DIRECTORY ==> PYTHON FILE (MODULE) DIRECTORY/FOLDER ==> PACKAGE ==> TREE TYPE OF HIERARCHY ==> PACKAGE package ==> modules + __init__.py ========================================= File Handling: ============== Why files? ========== to store the data permanently ==> files ==> Different types of files: 1) Text files .txt 2) Binary Files image files, audio files, video files etc. How to open the file: ===================== Syntax: file-pointer = open("file-name.txt", "mode-name") File modes: =========== w-mode ==> writing into file ============================= ==> open the file with 'w' mode: if the file is not available ==> 'w' ==> create the new file if the file is available ==> open that existing file by deleting all the content. r-mode ==> reading-mode ======================= ==> we can use to open the existed file for reading purpose ==> no modification while r-mode. ==> if the file is not existed ==> r-mode can give the error. file not found error. a-mode ====== ==> a-mode can create the new file with specified name if it is not existed. ==> a-mode can also open the existing file for reading and writing both. ==> cannot overwrite the data in the file. w+-mode ======== ==> write + read r+-mode ====== ==> read + write 100-lines writing is possible after 100-lines a+-mode ======= append + read x-mode: ======= exclusive mode ==> writing purpose ==>like the w-mode, it can create the new file for only writing but it can give "file existing error", when we can use this to open the existing file. # File Modes fp = open("abcd.txt","w") fp1 = open("pqrst.txt","r") fp2 = open("xyz.txt","a") fp3 = open("pqrst.txt","a") fp4 = open("abc.txt","w+") # fp5 = open("pqrst.txt","w+") fp5 = open("pqrst.txt","r+") # fp6 = open("pqrst.txt","x") fp6 = open("ravi.txt","x")