----BEGIN CLASS---- [13:26] #startclass [13:26] vharsh, that would be awesome! [13:26] Roll Call [13:26] Bhavin Gandhi [13:26] Avik Mukherjee [13:26] Harsh Vardhan [13:27] Ashwani Kumar Gupta [13:27] Deepika Upadhyay [13:27] Mahendra Yadav [13:27] Vivek anand [13:27] Abhishek Singh [13:30] Gaurav Sitlani [13:30] Akshay Gaikwad [13:30] Yurii Pylypchuk [13:31] Okay [13:31] Anyone wants to show me the function which counts the number of core? (from the session the otherday) [13:32] kushal, may i? [13:32] anyone [13:32] https://notebooks.azure.com/technotron/libraries/dgplug/html/summertraining.ipynb [13:33] kushal, Number of core as in CPU-core? [13:33] avik, ? I can not see any such code in that playbook [13:33] vharsh, Yes [13:34] kushal, I want to show the code but I'm having network issues :( [13:34] kushal, i am sorry! [13:35] i didn't save the other day [13:35] avik, :) [13:35] Anyone else? [13:35] Who else could not do this? [13:35] kushal, THere's a platform module(I have never used this one) and the regular file system way. Is it okay if I do it directly? [13:35] https://paste.fedoraproject.org/paste/-eAFkuNl0at3ONLDUXYWXQ [13:35] i could not do this [13:36] vharsh, we asked to read /proc/cpuinfo file [13:36] kushal, ok [13:36] yurii, Thanks for telling us. [13:36] yurii, we will do together then. [13:36] fine [13:36] kushal, uploading. slow network [13:37] kushal, https://paste.fedoraproject.org/paste/YKje7LmTv7ggczyfK6shsw [13:37] yurii, here is the /proc/cpuinfo from my computer [13:38] ashwanig, nice :) [13:38] yurii, For each processor there is an entry. [13:38] kushal, bhavin192 first did this :) [13:38] yurii, can you tell me how many entries in that? [13:38] count manually [13:40] sorry i do not anderstand what to count [13:41] kushal, I am using a fresh installed fedora in desktop , having issue error in fedora.repo file I guess I updated it , no net running ,tried commenting mirrorlist and uncommenting baseurl [13:41] No luck [13:42] yurii, can you see the lines with "processor" ? [13:42] deepika, we can talk about it after the session [13:42] Sure ,kushal :) [13:42] here is my solution to the problem https://paste.fedoraproject.org/paste/nI8-y40Y6kkO6C0hmE8BRQ [13:42] kushal i am having some error in code . https://repl.it/JqTv/11 [13:42] kushal - is there any files inside /cpuinfo [13:42] Roll call: Anu Kumari Gupta [13:43] yurii, /proc/cpuinfo is a file [13:43] yurii, can you please cat the file in your computer? [13:43] ok [13:43] https://paste.fedoraproject.org/paste/~SpyLFJIYLcYODRVSd6YhQ [13:43] kvy_, first problem, you opened the file, but did not close it. [13:44] kvy_, next, not every line has : in it [13:44] i have 4 procassors [13:44] yurii, good, how did you find that? [13:44] kushal ok i am changing my code. [13:45] proc 0, proc1, proc 2, proc 3 [13:45] bhavin192, isn't that returning the result without closing the file? [13:45] yurii, now look at the code pasted by ashwanig [13:45] ashwanig, as it is using with I think it will take care of that [13:46] yes i so and it is clear now for me [13:46] yurii, or from bhavin192 https://paste.fedoraproject.org/paste/nI8-y40Y6kkO6C0hmE8BRQ [13:46] Anyone else any question? [13:46] thank you [13:46] ! [13:47] ! [13:47] next [13:47] next [13:47] ! [13:47] how about using os.system("lscpu") ? [13:47] Is mine correct? [13:47] ! [13:47] sitlanigaurav[m], This case I gave a particular way to find the answer. [13:47] next [13:47] anuGupta, no, that's physical cores [13:48] next [13:48] kushal, I didn't understand how will with take care of closing the file in bhavin192 code [13:48] [13:48] bhavin192, Do you want to answer ashwanig? [13:49] bhavin192, btw, you don [13:49] ashwanig, "with" closes the file as the code block ends [13:49] bhavin192, btw, you don't have to write :param: None [13:51] bhavin192, okay, got it [13:51] kushal, but still I have similar doubt as ashwanig. if it returns from that block, how it closes the file. Is it something like garbage collection? [13:52] bhavin192, Not like garbage collection, but it closes the file even if there is any error. [13:52] next [13:52] why in some programs we start with #!/usr/bin/env python and some (like we use as modules) do not [13:53] yurii, good question. [13:54] http://dpaste.com/038GSYQ.txt [13:54] yurii, Anything which is supposed to be an executable, starts with #! to mention which interpreter to use to for that script. [13:54] Modules are not executable, people import modules into their code, that is why they don't have #! [13:55] ok [13:56] next [13:57] Can we write some more code? [13:57] yes [13:57] Okay [13:58] sure [13:58] kushal it shows 0 now https://repl.it/JqTv/12 [13:59] kvy_, yes because you are updating the `cpu_core` value in each iteration [14:00] kvy_, we have to count from the whole file not line by line [14:01] Now, a bit more fancy. [14:02] Write me a code/function, which will take a python file name as input, and then tell me which all modules have been imported in that file. [14:04] kushal, the python file will be in the same directory? [14:04] ashwanig, can be in anywhere, we will pass the full path of the file. [14:05] kushal, okay [14:14] kushal, https://paste.fedoraproject.org/paste/Yjj~RpYRNRs3EB6XQhsmcQ [14:15] ashwanig, from os import path [14:15] This case? [14:15] oh sorry [14:15] ashwanig, no need to say sorry [14:15] ashwanig, also for, # import os [14:15] :) [14:16] kushal, http://dpaste.com/2FQTHV0.txt [14:17] Working on the from os.path import xyz thing now [14:21] You all should show me the first version at leaset [14:21] * least [14:23] kushal, Should # import os also show up the os module in usages? [14:23] vharsh, nope :) [14:23] In my program it will not be as line beginswith -> '#' [14:24] vharsh, so what about import os # import sys [14:24] :) [14:24] Everyone please remember, the code does not have to be perfect. [14:24] kushal, Import sys will be ignored [14:25] vharsh, good [14:25] kushal, import os#import sys will give weird results. [14:28] Hello everyone [14:29] Ravi, Hello, a session is going on. [14:29] So please wait for some before we talk here. [14:31] kushal, http://dpaste.com/18YCZCX.txt this fails for `from os.something.something import hello` [14:32] Okay [14:33] Anyway, we will keep checking the code, and improve slowly. [14:33] it gives `os.something` as output [14:33] People should make github repos which will contain each problem in a different directory. [14:33] Everyone ^^^^ [14:34] Also read this with time https://pymotw.com/3/ [14:34] Not everything in one day. [14:39] kushal, http://dpaste.com/1HAZ4A2.txt [14:39] Done. [14:40] kushal, https://paste.fedoraproject.org/paste/qh-nqbtK1DkJ6AMHXzUo1g [14:40] vharsh, i will check [14:40] I was getting the index of '.' and then getting rid of the `from` keyword. [14:40] missing the comment testcase [14:40] vharsh, btw, your code tells me you missed the actual problem statement [14:40] I asked for a function :) [14:41] ashwanig, try to do it without regex [14:41] kushal, okay [14:41] kushal, I was afk, will do it now [14:41] That is okay. [14:44] kushal: in https://paste.fedoraproject.org/paste/VI2MRl1ZQiFlAL3VIACy7w/ how should i use modules.startswith() ? [14:45] sitlanigaurav[m], even before that, I asked for a function which takes a file path as argument. [14:46] I'll update that [14:46] kushal, http://dpaste.com/15YDD7E.txt Updated :) [14:47] kushal, https://paste.fedoraproject.org/paste/AtcPy5MXnuEw44BmKpqhwA [14:47] Because we start digging more into the code we are writing. [14:48] I have few more things to say. [14:48] But, I guess people are busy writing code [14:49] we're here [14:49] who ever names the function as moduleFinder [14:49] That camelCase is Java style [14:49] In Python do module_finder [14:49] Who all read the ssd.eff.org ? [14:49] I am ending the session and then we can continue the discussion [14:50] Roll Call [14:50] Harsh Vardhan [14:50] Bhavin Gandhi [14:50] Ashwani Kumar Gupta [14:50] Deepika Upadhyay [14:50] Gaurav Sitlani [14:50] Devesh Verma ----END CLASS----