----BEGIN CLASS---- [13:31] #startclass [13:31] Roll Call [13:31] mbuf ,kushal ok :) [13:31] Robin Schubert [13:31] Samridhi Agarwal [13:31] Ashwani Kumar Gupta [13:31] Soumam Banerjee [13:31] pooja kumari singh [13:31] Sandesh Patel [13:31] Yurii Pylypchuk [13:31] Akshay Gaikwad [13:31] Abhishek Singh [13:32] Krishnanand Rai [13:32] Anu Kumari Gupta [13:32] Bhavin Gandhi [13:32] Pradhvan Bisht [13:33] Vivek Anand [13:33] Okay. [13:33] next [13:33] Any questions related to file handling? [13:34] We will do a little bit of quiz, and then go to writing code. [13:34] Roll Call: Onyinye Madubuko [13:36] ! [13:36] mext [13:36] next [13:36] If we use with statement it closes the file when it leaves the with block, [13:37] yes [13:37] What is the better way to open a file, directly call open? or using the with statement? [13:37] I have seen with statement with other things as well [13:37] bhavin192, Yes. [13:37] ! [13:37] kushal, with statement [13:37] bhavin192, all of them have similar use cases, with will take care of many things for you. [13:37] Like closing socket connection or file closing or similar things. [13:37] next [13:38] kushal, then how it determines that it has to call the close or other similar methods related to other functions [13:38] bhavin192, I will show later. [13:38] bhavin192, Today, after the session. [13:38] kvy_, question? [13:38] Anyone wants to answer my question? [13:38] kushal, Okay. [13:38] kushal wait i need some time. [13:40] kushal, which question? [13:40] with with statement [13:40] with [13:41] Yup. Thanks. [13:41] kushal Can we read file in a mode ? [13:41] kvy_, means? [13:41] you open in Read mode if you want to read. [13:42] kvy_, you mean append mode? [13:42] what if i want to do both. [13:42] read as well as write. [13:42] kvy_, man 2 open [13:43] kvy_, First read that manual page, search if you have questions, or come here and ask. [13:43] But, first read that man page. [13:43] next [13:43] kushal ok [13:43] So, the first problem. [13:44] Write a function, when calling it, it will return a tuple, first value is the name of the distribution, second value is the version id of the distribution. [13:44] Hint: read the content of /etc/os-release for the information. [13:45] Go ahead and write it. [13:48] Roll call: Deepika Upadhyay [13:49] Remember to ping me when you are done. [14:01] kushal, done [14:01] kushal: me too [14:01] I think [14:01] ash [14:01] ashwanig, what is to be done? [14:02] avik, check pm [14:02] Unless you people show us, how to know if done right way or not :) [14:02] kushal, done. but the notebook is not updating the html preview :-/ [14:02] kushal, Write a function, when calling it, it will return a tuple, first value is the name of the distribution, second value is the version id of the distribution. [14:02] Hint: read the content of /etc/os-release for the information. [14:02] Go ahead and write it. [14:02] https://paste.fedoraproject.org/paste/yK7S~weBbB84h03uQ2aJOA [14:02] sorry [14:02] kushal, https://paste.fedoraproject.org/paste/K~VrhDGhE7sZOeJsjbVezg [14:03] ashwanig: we did it quite similar :D [14:04] :) [14:04] Now try this [14:04] !cat /etc/os-release [14:04] in the notebook server, can you see any difference between fedora and ubuntu os-release file\? [14:04] we will also wait for others [14:06] kushal, Ubuntu has double quotes around name and version id [14:06] yes [14:06] so make sure to remove those in your function [14:06] it has to be generic [14:11] kushal, done. [14:11] show me the code :) [14:16] kushal, created new notebook, was having issues with old one https://notebooks.azure.com/bhavin192/libraries/dgplug/html/summertraining-new.ipynb [14:17] https://paste.fedoraproject.org/paste/TtuF-PuxzMRoyafbyYA6WQ [14:17] kushal: https://paste.fedoraproject.org/ [14:19] kushal, trying to decide which one is more readable. the first one line[5:-1].strip() or the second one [14:19] https://paste.fedoraproject.org/paste/m04xabH3Jh42tRF2K7j0Pw [14:19] Please have a look at everyone's code [14:20] and comment [14:20] We learn in group [14:20] Help you friends [14:22] I didn't run all of the snippets, but they do not differ a lot [14:23] Why is everyone using a for loop? [14:23] san-D, knrai you have similar solution. but san-D's code was more readable for me [14:23] A regex will be faster [14:23] mbuf: we didn't learn regexs yet ;) [14:24] schubisu, ohh! common! [14:24] https://repl.it/K3W3/0 [14:24] kushal, is it okay? https://notebooks.azure.com/technotron/libraries/dgplug/html/summertraining.ipynb [14:24] reading the entire line, then matching for a keyword is very slow; this file happens to be small; think about a file of size in GB [14:26] I tried writing the code but my code is not returning any output and it is not even showing any error https://paste.fedoraproject.org/paste/X-LF8oU8xYb-DIirSX-PzA [14:27] https://notebooks.azure.com/n/IVnJfosUBL0/notebooks/summertraining.ipynb [14:27] kushal, PM? [14:27] samridhia, did you call the function? [14:27] Someone help samridhia [14:28] ashwanig, no [14:28] samridhia, also you didn't close the file [14:28] will someone review my code? [14:28] anuG, sure [14:28] :) [14:28] brb, changing network [14:29] anuG, can't see the solution for this problem. I was facing same issue. https://notebooks.azure.com/anu020815/libraries/dgplug/html/summertraining.ipynb [14:29] anuG, which file? [14:29] strip() will remove \n and the spaces on left or right. Also, strip("\n") will only remove "\n" even if it sees the spaces. I guess .strip() is better for this [14:29] mbuf: pm? [14:30] vivek_, But there are also quotes " [14:30] ashwanig, summertraining.ipynb [14:30] why my output is showing ubuntu 16.04.3? [14:30] anuG, can't see your solution [14:30] samridhia, call the function with a variable. then print the variable. and yes, as ashwanig said close the file, or use 'with' to open the file [14:31] oh [14:31] poojaencoded: which machine executes the code? [14:31] avik , ashwanig trying that. [14:31] ashwanig, still? [14:31] poojaencoded, cause Azure Notebooks uses Ubuntu 16.04.3 container images [14:31] schubisu, sure! [14:31] kushal done [14:31] here is the link https://repl.it/K3WA/3 [14:32] ! [14:32] okay got it [14:32] https://notebooks.azure.com/n/IVnJfosUBL0/notebooks/summertraining.ipynb [14:32] anuG, can't see. use pastebin [14:32] anuG, give the exact link i think you are giving the link of all ipynb [14:32] yeah pastebin is better [14:33] https://paste.fedoraproject.org/paste/FDVOiS5JJT1n8eY5Y1Ecug [14:34] anuG, looks good [14:34] anuG, seems coreect [14:34] oops correct [14:34] anuG, But you can use only single " inside strip() [14:34] :) , ashwanig, how? [14:35] ashwanig can you check my code https://repl.it/K3WA/3 [14:35] ok wait [14:35] anuG, strip('"') [14:36] https://paste.fedoraproject.org/paste/BpNkwAgU9lk-Vo-CqNnZEg [14:36] thanks avik, ashwanig got it working https://notebooks.azure.com/n/aRIlccoSXi0/notebooks/summertraining.ipynb [14:36] kvy_, I think its correct [14:36] glad i could ! :D [14:37] how is that single " within strip removing both at the ends? [14:38] samridhia, can't see the solution :( seems like strange problem with Azure notebooks [14:38] oops [14:38] yes it will [14:38] https://notebooks.azure.com/n/boYK0n3XDGg/notebooks/summertraining.ipynb ,why output is not showing ? [14:39] bhavin192, my azure notebook kernel is only working when i restart it again and again wonder why [14:40] poojaencoded, you have to call the function right? [14:40] samridhia, for me it keeps restarting [14:40] poojaencoded, you will have to call the function :) [14:40] poojaencoded you do not print name and version anywhere in the code. [14:41] poojaencoded, seems like you are missing '_' while calling. [14:43] poojaencoded, run it in terminal or any offline editor, its working. but we needed VERSION_ID, not VERSION [14:44] Next problem, write a function which will tell me the number of cores in your computer [14:44] using /proc/cpuinfo [14:44] pooja_, has called the function from inside the print fuction [14:45] it is ok [14:45] kushal If we call read function twice it give result once why ? [14:48] kvy_, read the python documentation for the same :) [14:48] kushal: you know, the day before I left. I actually had a small accident [14:48] kushal ok [14:49] was cycling with slippers, and heavy rains and I slipped [14:52] sayan: http://www.bicycle-riding-for-boomers.com/adult-tricycle.html [14:52] kushal, https://paste.fedoraproject.org/paste/B1gx1wGxMZtxWB9iSdfhjQ [14:53] soumam007, i got the output. That time it was not showing because of poor net connection [14:54] https://paste.fedoraproject.org/paste/~SpyLFJIYLcYODRVSd6YhQ [14:56] ashwanig , my /proc/cpuinfo only shows processors and steppings [14:56] https://paste.fedoraproject.org/paste/TiLSeA9tTUOO75NWrYkzAQ [14:56] anuG: maybe we could stop the loop when cores are found, so it doesn't need to loop to the end [14:57] deepika, press Ctrl+F and find 'cores' [14:57] yup, just saw your break :) [14:58] https://paste.fedoraproject.org/paste/y3nTSQA0TT-hbrqz-sW-OA [14:58] ashwanig , okay but for code ? [14:59] deepika, didn't get you? [15:00] kushal, should it display physical cores? [15:00] ashwanig , no problem , fixed it , thanks :) [15:00] mbuf: There? [15:01] Anyone experienced in GRUB? [15:01] thebigj, yes [15:01] mbuf: How are you? [15:02] mbuf: That was yes for There or experienced in GRUB? [15:02] thebigj, good; ask your question [15:02] thebigj, the session is going on. [15:02] thebigj, please talk in pm. [15:02] thebigj, after the session or PM [15:02] https://notebooks.azure.com/technotron/libraries/dgplug/html/summertraining.ipynb [15:03] bhavin192, to start with, counting total threads will do. [15:03] I want you all the ask and check among yourselves. [15:03] kushal: /proc/cpuinfo shows 4 processors and `cpu cores : 2` for each of them do i need add them all? [15:03] answer is 4 [15:05] avik: you code is not updating in notebook [15:06] s/you/your [15:06] san-D, seems like we all are facing issue with Azure notebooks :( [15:08] https://repl.it/JqTv/11 i need someone help [15:09] san-D, will fix that. maybe, azure is not autosaving stuff today. [15:09] https://paste.fedoraproject.org/paste/B4XyHe8wGi05KAZBkV68EA [15:09] avik, even after auto saving the preview is not updating [15:10] kvy_, line.split is not returning two values [15:10] means no : in the line [15:11] but when i read and print file then it seprated by : [15:11] kvy_, may be it is happening at "bugs :" [15:12] bhavin192, why are you counting 'processor'? [15:13] ya it's printing in the above way as bhavin192 tells cpu core : 2 [15:14] ashwanig, cause we have to count total virtual cores [15:14] bhavin192: what gives no. of cpu cores [15:14] `cpu cores : 4` or counting "processor" [15:15] bhavin192 will you please correct my code. [15:15] knrai, cpu cores gives number of physical cores [15:15] bhavin192, got it [15:15] bhavin192 i enable to correct that [15:16] Everyone [15:16] bhavin192, the 'cpuinfo' file contains the details for each virtual core one after another right? [15:16] Slowly you will see that many system programs are nothing but fancy way to dealing with configuration files. [15:16] kvy_, seems like there are some lines where there is no ":" [15:16] ashwanig, IIR [15:17] *IIRC yes [15:17] bhavin192 ok [15:19] bhavin192, https://paste.fedoraproject.org/paste/-eAFkuNl0at3ONLDUXYWXQ [15:20] I will pass more problems to solve in the channel tomorrow. [15:20] Roll Call [15:20] kumar vipin yadav [15:20] Deepika Upadhyay [15:20] Avik Mukherjee [15:20] Robin Schubert [15:21] Sandesh Patel [15:21] pooja kumari singh [15:21] Abhishek Singh [15:21] Samridhi Agarwal [15:21] anu kumari gupta [15:21] Mohit [15:21] Ashwani Kumar Gupta [15:21] Krishnanand Rai [15:21] Bhavin Gandhi [15:21] kushal can i add more then one blog at http://students.planet.dgplug.org/ ? ----END CLASS----