----BEGIN CLASS----
[14:00] <kushal> #startclass
[14:00] <kushal> Roll Call
[14:01] <storymode7> Mayank Singhal
[14:01] <kvy> Kumar Vipin Yadav
[14:01] <inquiridortechie> Neeraj Kumar Arya
[14:01] <sehenaz_> Sehenaz Parvin
[14:02] <kushal> anyone else?
[14:02] <VirtualRcoder> Shubham Sharma
[14:02] <kushal> Okay
[14:03] <kushal> anyone already read the functions chapter? https://pymbook.readthedocs.io/en/latest/functions.html ?
[14:03] <man-jain> Manank Patni
[14:03] <jeet__> Amitrajit Bose
[14:03] <kvy> kushal, yes
[14:04] <inquiridortechie> kushal, yes
[14:04] <jeet__> yes
[14:04] <kushal> anyone else?
[14:04] <storymode7> yes
[14:04] <kushal> who all did not read that chapter yet?
[14:05] <kushal> We are having a lot of sessions on other things for last few weeks, means we are gong super slow in Python land.
[14:05] <kushal> We need you all read of your own.
[14:05] <kushal> Next, we have two major chapters, functions and file handling.
[14:06] <kushal> The important point to remember, if you open a file, always remember to close it.
[14:06] <kushal> That goes to most of the other things in computer, network socket, or database connection.
[14:06] <kushal> If you open, you close.
[14:06] <kushal> Python provides with statements to help you out in that easily
[14:06] <kushal> https://pymbook.readthedocs.io/en/latest/file.html#using-the-with-statement
[14:08] <kushal> can the new folks start trying out the files chapter and ask any doubts here
[14:08] <kushal> ?
[14:08] <kushal> Also any other doubts?
[14:08] <kushal> Feel free to ask.
[14:10] <j605> !
[14:10] <kushal> next
[14:10] <j605> does Python automatically convert between DOS and Unix line endings?
[14:10] <priyankasaggu119> Priyanka Saggu
[14:12] <soniya29> Roll call: Soniya Vyas
[14:13] <kushal> j605, no iirc.
[14:13] <kushal> j605, I don't remember when was the last time I had to use/access a file with DOS ending.
[14:15] <j605> kushal: thanks. I had the doubt since the file mbuf used in the previous class had DOS endings
[14:15] <j605> <eom>
[14:16] <kushal> who all are trying out the files chapter?
[14:17] <jeet__> me
[14:17] <storymode7> me
[14:17] <kvy> kushal, me
[14:17] <inquiridortechie> me
[14:17] <kushal> Okay
[14:23] <pooja_s> Roll call: sulakhe Pooja
[14:27] <devesh_verma> Roll call: Devesh verma
[14:28] <storymode7> !
[14:29] <kvy> !
[14:32] <kushal> next
[14:32] <storymode7> If I open a file inside a function, and then exit the function without closing the file, does the file remain open? As the variable used to store the file object is destroyed after the function ends.
[14:33] <kushal> storymode7, generally yes.
[14:33] <storymode7> kushal: Thanks <eom>
[14:33] <kushal> storymode7, Because you don't know when the garbage collector will work, and the file handler is in the OS level.
[14:33] <kushal> storymode7, that is why use with statements.
[14:34] <kushal> So that you don't have to worry about closing.
[14:34] <kushal> next
[14:34] <kvy> kushal, While you copy a file into another then you use sys.argv[1] here which file is opening and how ? <eof>
[14:34] <kushal> Good qustion.
[14:34] <kushal> * question.
[14:35] <kushal> kvy, Do you know about command line arguments?
[14:35] <kushal> In any language?
[14:35] <kvy> kushal, yes
[14:36] <kushal> kvy, in Python, the argv attribute of the sys module holds all of the command line arguments.
[14:36] <kushal> Do this.
[14:36] <kushal> Put the following two lines in a file.
[14:36] <kushal> import sys
[14:36] <kushal> print(sys.argv)
[14:36] <kushal> or better add a sha-bang line in the top.
[14:37] <kushal> #!/usr/bin/env python3
[14:37] <kushal> and then try to execute the file with different arguments.
[14:37] <kvy> kushal, ok
[14:37] <kushal> say the filename is tryargv.py
[14:37] <kushal> ./tryargv.py
[14:37] <kushal> ./tryargv.py hello one two
[14:38] <kushal> ./tryargv.py hello one two 4 5 this is another long --list of arguments
[14:38] <kushal> And then check the output.
[14:38] <kushal> Tell me what do you understand from that output.
[14:39] <kvy> It display a list contain my file-name and the value i pass during execution
[14:39] <kushal> yes, means the executable file is always argv[0]
[14:39] <kushal> and then rest of them are the other arguments.
[14:39] <kushal> for example.
[14:40] <kushal> rm hello.py
[14:40] <jeet__> kushal, It is much similar to C language?
[14:40] <kushal> Here rm is the argument 0 and hello.py is the argument 1.
[14:40] <kushal> jeet__, yes.
[14:40] <jeet__> Understood.
[14:40] <kvy> kushal, ooh got it
[14:40] <kvy> thank you
[14:40] <jeet__> thank you
[14:41] <kushal> next
[14:41] <jeet__> !
[14:42] <jeet__> What will happen if I forget to use fobj.close()?
[14:42] <kushal> next
[14:42] <kushal> jeet__, the file handler will stay open and if you have opened too many files, you will not be able to open any more files on that computer.
[14:43] <jeet__> Alright. Thanks
[14:46] <kushal> Please let me know if you have finished reading that chapter.
[14:46] <kvy> kushal, Done
[14:47] <kvy> kushal, I am trying to do some real code. :)
[14:48] <kushal> If anyone has any other query, regarding to Python or LYM book or anything else, please ask.
[14:52] <jeet__> !
[14:52] <storymode7> !
[14:53] <kushal> next
[14:53] <jeet__> Need help with this thing, couldn't catch.; for i,line in enumerate(fd):
[14:53] <jeet__> where fd is a file pointer
[14:54] <kushal> yes.
[14:54] <kushal> jeet__, if you have a for loop on the fd, you will get each line in the for loop.
[14:55] <jeet__> Sure. But how is the second variable and enumerate helping?
[14:55] <kushal> jeet__, help(enumerate)
[14:56] <kushal> You will have to read the docs :)
[14:56] <jeet__> oops.
[14:56] <jeet__> Yes right
[14:57] <kushal> next
[14:57] <storymode7> Resolved now. Was curious about the number of files that could be opened. Found out it was 60.
[14:58] <kushal> 60?
[14:59] <kushal> How did you find that number?
[15:01] <storymode7> Yup. First I was opening a few files and tried to read their file numbers. After some time the file numbers started to repeat and stopped incrementing after 13. So I searched how to see opened files by a process and found that the process already had 60 files opened! I also checked file limit, and it turned out that 60 is per process file limit.
[15:01] <jeet__> !
[15:02] <kushal> storymode7, I never knew it.
[15:02] <kushal> next
[15:02] <jeet__> kushal, Why do we need to mention __name__=='__main__' before writing the main function part of the code?
[15:03] <jeet__> I mean, the program would do the same thing without that.
[15:03] <kushal> jeet__, wait for the modules chapter.
[15:03] <kvy> :)
[15:04] <jeet__> kushal, Okay :)
[15:05] <kushal> next
[15:06] <kushal> Any other questions?
[15:07] <kvy> kushal, nope
[15:07] <storymode7> Done with the chapter.
[15:08] <kushal> sehenaz_, are you trying the files chapter?
[15:10] <sehenaz_> kushal: yes i am trying. Actually i was completing the string chapter which was left out. but i have started trying the files chapter. :)
[15:10] <kushal> sehenaz_, Okay, no issues, go slow.
[15:11] <kushal> Who all finished the shellscripts link provided by bkero ?
[15:12] <sehenaz_> kushal: yes i guess i will be upto the class by this weekend.  just because of my semesters i am laging behind. I am really sorry for that.
[15:13] <kushal> sehenaz_, ah no issues.
[15:14] <kushal> Can we end the session now if there are no more questions?
[15:15] <kvy> kushal, yes
[15:15] <storymode7> I'm done for now. I Will ask later if I have anymore questions :)
----END CLASS----