----BEGIN CLASS---- [13:35] #startclass [13:35] Roll Call [13:35] Vivek Anand [13:35] devsh verma [13:35] Sandesh Patel [13:35] Samridhi Agarwal [13:35] Krishnanand Rai [13:35] Priyanka Sharma [13:35] Soumam Banerjee [13:36] Yurii Pylypchuk [13:36] Robin Schubert [13:36] Akash pathak [13:37] kumar vipin yadav [13:37] Bhavin Gandhi [13:38] Okay, questions related to modules? [13:38] Ashwani Kumar Gupta [13:39] ! [13:40] roll:pooja kumari singh [13:41] Roll Call: Abhishek Singh [13:44] next [13:44] Roll Call: Deepika Upadhyay [13:44] next [13:44] I didn't understand this part. https://pymbook.readthedocs.io/en/latest/modules.html#all-in-init-py [13:45] ashwanig, Okay [13:45] let me try to write one example [13:45] Also why all modules be public? If private modules are not accessible then what is the use? [13:45] Anu kumari Gupta [13:46] s/why/why not [13:46] ashwanig, wait, one by one. [13:46] kushal, ok. sorry for that. [13:47] no problem [13:47] ashwanig, say you have a module, which as the actual function call addition [13:47] people will import your module and use it. [13:47] But, the addition function needs 24 more modules, and that may change with time. [13:48] So, you have written a few modules which should only be used by the addition function, but not anyone else. [13:48] Then you can replace the code inside, without changing the things below. [13:48] __all__ helps in that [13:48] any more question [13:49] ! [13:50] kushal, didn't understand [13:51] Can you rephrase this line please? - 'Then you can replace the code inside, without changing the things below.' [13:54] Roll Call: Onyinye Madubuko [13:55] next [13:56] ashwanig, wait, showing [13:56] When we run a .py file using modules, it compiles the modules and store the .pyc in __pycache__ and uses it when we call function from that module. This avoids recompilation of modules, right? [13:56] s/using/which is [13:56] [13:57] yes iirc [13:58] kushal, Okay understood. [13:58] ashwanig, wait, slow network [13:59] kushal, okay :) [13:59] ashwanig, https://paste.fedoraproject.org/paste/0EFnmt3JxSctVaTyl-4cZg [13:59] say people used add function from bar.py before, now if they use add function from a new bar.py (I gave the name bar2.py for here), they can still use add function [14:00] But the internal code has been changed. [14:00] This is also what we talk about public API. [14:02] kushal, so how __all__ helps here? [14:02] ashwanig, this is still stupid example, in a real case, you will only put add in the __all__ [14:02] so that people can use that [14:03] oh okay. got it [14:03] next [14:03] Anyone else? [14:03] No more questions? [14:04] ! [14:04] next [14:05] It is possible to import a submodule with from name import submodule [14:05] yes [14:06] and as well as with import name.submodule are both same? [14:06] yes [14:06] >>> import os.path [14:06] >>> from os import path [14:06] bhavin192, ^^^ [14:07] kushal, ah! and if we want only one function we can do from os.path import funnmae [14:07] bhavin192, Yes [14:07] ! [14:07] right? [14:08] next [14:08] What is the use of private submodules or private functions that are not in __all__ ? They are not accessible right? [14:08] ashwanig, you may need them in your public submodules. [14:09] ashwanig: They are accessible, they aren't imported when you do a `from this import *` [14:09] Generally, you should avoid * imports anyway. Just adds too many stuff to the current namespace. [14:09] maxking, and now they will only do from module import * :p [14:09] maxking, I was skipping that :) [14:10] maxking, got it [14:10] kushal: oops! [14:10] ! [14:10] maxking, hahaha [14:10] next [14:10] Hello everyone [14:10] those who finished reading module and free please help me [14:10] because of some issue i enable to attend some session so i read logs and practice [14:10] but i got error in some code [14:10] will you please help me to solve those error [14:10] I am sending link of those codes [14:10] 1. DATA STRUCTURE https://repl.it/KDN7/8 [14:10] 2. LISTS https://repl.it/KWZc/3 [14:10] And need some help in these problem [14:10] 1. MEMORY https://repl.it/KW0S/1 [14:11] kvy_, show only one code, and error, we can help you wit that [14:11] one by one. [14:11] next [14:12] kushal ok [14:12] kvy_, so show us one, and ask [14:13] https://repl.it/KDN7/8 [14:13] i am gating error in my this code [14:14] in line 7 [14:14] kvy_: Missing a closing ) in the line 6. [14:15] kvy_, yes, line 6 is the problem [14:15] kushal maxking got it [14:15] kvy_, you have a lot of syntax errors related to print() [14:16] max of them are just the print() [14:16] :) [14:16] but all my code will work properly in terminal. [14:17] kvy_, can not be [14:18] kvy_, with python3 ? [14:18] i save hole code in a .py file and than runing . [14:18] my code will not show any error. [14:18] bhavin192, with python2 also it will show error [14:19] but when i past it here than it is showing error. [14:19] kvy I just tried running your code in my terminal , shows the same errors. [14:21] kvy_, you are using python less than 3 in terminal [14:21] but in repl you are using ver. 3 [14:21] i tried it terminal not giving errors in 2.7 but giving for 3 [14:22] soumam007, I tried it with 2.7.12 I got errors [14:22] I am getting error for both [14:22] ya i am using python 2.7 [14:23] kvy_, write python3 in the terminal [14:23] and try asap [14:23] soumam007, :) [14:23] next [14:23] the errors [14:23] soumam007 it show python 3.6.1 [14:24] ashwanig, will sort it after class , lets resume [14:24] kvy_, go for that even [14:24] Now, for Python, we call it batteries included. [14:24] Because the language standard library has a large number of modules for you. [14:24] https://docs.python.org/3/library/index.html [14:25] soumam007 ok i will. [14:27] and i change hole my code but that still show error in line 134 [14:27] here is the link https://repl.it/KDN7/11 [14:27] Next, we will do some quiz, people who already know the answers, please do not answer, it will mostly for new people. [14:27] There is an Operating System module. [14:27] https://docs.python.org/3/library/os.html [14:27] yeah because the value its getting is string but you have given %d. change it to %s it should solve the issue [14:28] kvy_, [14:28] devesh__verma, Please stop cross talking [14:28] sorry kushal [14:28] From that module, who can tell me the name of the function which can give me the names of all the files inside of a given directory? [14:29] Answer: is in there [14:29] May I guess? [14:31] anuGupta, yes please :) [14:32] Is it dir()? [14:32] may i [14:33] Oops from the link given? I thought you are asking in general [14:33] anuGupta, Nope, dir is a builtin function [14:33] anyone please tell what you read [14:34] getcwd() [14:34] os.listdir( path ) [14:34] kvy_, getcwd tells the current working directory. [14:34] it is listdir() [14:34] listdir() [14:34] knrai, Correct :) [14:34] yup [14:34] Now, everyone try that out. [14:35] kushal is it the style of printing str only [14:35] ? [14:35] soumam007, which is? [14:35] i thought in that syntax integer values cant be printed [14:38] soumam007, which syntax? [14:38] sorry that was my misconception, too many formats of printing outputs in python :P [14:38] kushal i got it ,leave :) [14:38] Okay [14:38] people tried to print all the file names? [14:38] yes [14:39] yes [14:41] Okay [14:41] next [14:41] oops [14:42] Try to write one line code, which will print me the name of the terminal emulation you have in your system. Hint: it is inside of an environment variable called TERM [14:42] kushal: echo $0 [14:43] ? [14:43] deepika, nope [14:43] deepika, also that is shell :) [14:44] deepika, We are doing Python here. [14:44] Sorry in python yeah [14:44] For example, my terminal is of type xterm-256color [14:46] kushal do you mean what is that black terminal we are using because i have seen beside by normal terminal i have Xterm [14:46] os.environ['TERM'] [14:46] ? [14:46] ashwanig, you should print that :) [14:46] print(os.getenv("TERM")) or print(os.environ["TERM"]) [14:46] bhavin192, Yup [14:47] mine is also xterm-256color :) [14:48] same here [14:49] same here [14:50] but now you know how to access any environment variable, correct? [14:50] Mine too [14:51] yes [14:51] kushal yes [14:52] What is the bash command to print all the environment variables? [14:53] I guess printenv [14:53] ? [14:53] printenv [14:53] anuGupta, you can always try it out fast, or search fast, and then answer :p [14:53] No one is stopping you :) [14:53] env [14:53] You just have to be fast :) [14:54] both are working here env and printenv [14:54] bhavin192, yup [14:54] :P [14:55] For the weekend, start reading the chapters on file handling and exceptions [14:55] i will start pinging the guest speakers now. [14:55] Roll call [14:56] Ashwani Kumar Gupta [14:56] Sandesh Patel [14:56] Krishnanand Rai [14:56] Deepika Upadhyay [14:56] Priyanka Sharma [14:56] kumar vipin yadav [14:56] Yurii Pylypchuk [14:56] Soumam Banerjee [14:56] Anu kumari Gupta ----END CLASS----