[16:24:24] [## Class Started at Thu Aug 25 16:24:24 2016 ##] [16:24:24] startclass [16:24:34] Roll Call [16:24:37] Pabitra Pati [16:24:40] Prashant Jamkhande [16:24:41] Harsh Vardhan [16:24:42] tabrez khan [16:24:49] Saurav Saha [16:24:49] Aman Kumar [16:24:50] Anjali Pardeshi [16:24:51] Avik Mukherjee [16:24:51] Amey Jain [16:24:55] Abhishek Gupta [16:25:05] Kshitij [16:25:06] Shantanu Acharya [16:25:20] Mamoon Manzoor [16:25:27] Rhitik Bhatt [16:25:45] Anupama Mandal [16:25:46] Poonam Jadhav [16:25:48] sandeep kumar choudhary [16:27:11] Okay [16:27:24] Jogender KOta [16:27:24] Can we move on to next chapter in the book? [16:27:30] LambaIns1 is now known as RhitikBhatt [16:27:41] yes [16:27:44] dhritishikhar___ is now known as dhritishikhar [16:27:45] kushal Yes [16:27:51] yes [16:27:56] yes [16:27:57] Yes. [16:28:14] yes [16:28:15] Yup [16:28:24] yes [16:28:27] Aswin Devarajan [16:28:36] Roll Call:Varsha R [16:28:43] Okay [16:28:55] Anushil Kumar [16:30:22] okay [16:31:03] https://shellshare.net/r/summertraining [16:33:07] Modules [16:33:19] We try to reuse code when ever possible. [16:33:26] Functions are the smallest unit for that. [16:34:12] We try to put in all the functions, constant values related into modules, which in turn can be reused by many projects. [16:34:46] Generally any .py file can be used as a module [16:34:55] Let us go to the shell to see a simple example [16:34:57] ! [16:35:02] next [16:35:17] did not got the concept of module! [16:35:27] avik, let me show you [16:35:31] can you please explain once more? [16:35:33] look at the shell [16:35:38] ok [16:36:46] We didn't call the function [16:36:48] because we never called the function [16:36:52] Since the function is not called [16:36:53] Function wasn't called [16:36:54] Correct :) [16:36:57] nothing printed because function wasnt called [16:36:58] Good [16:37:02] It's just the structure [16:39:58] Do you have any questions still now? [16:40:00] ! [16:40:05] next [16:40:16] ! [16:40:38] How is a module different from a class? I mean it felt same like using a class [16:40:59] avik, A module is a source code which can contain many classes, functions [16:41:11] oh [16:41:12] which can be shared with others. [16:41:16] next [16:41:22] we need to be in same directory for doing that ,how can we do if it is in different directory ? [16:41:23] but the idea is same, isnt it? [16:41:40] avik, no, we will see why in future. [16:41:48] ok :) [16:41:54] avik, it takes time to have clear ideas, so don't worry [16:42:04] :D [16:42:04] anushil05_, Good question, we will see that in some time. [16:42:27] any other question anyone? [16:42:56] ! [16:43:16] Can I ask a question related to classes ? [16:43:29] SRvSaha, ask :) [16:43:46] Is there any way to do something like private in python class data members as in Java ? [16:43:58] That gives additional security [16:44:00] ! [16:44:31] SRvSaha, first point: private variables are not for security. They have nothing to do with security [16:44:48] SRvSaha, they help so that people by mistake do not update them. [16:44:58] You can do that by mangling the variable names [16:45:26] mangling ? [16:45:41] SpEcHiDe: ROLL CALL: Shrimadhav U K [16:46:35] SRvSaha, let us see an example [16:46:46] brb in 1 minute [16:46:49] Sure :) [16:47:18] in the shell everyone [16:47:24] SRvSaha, good point btw [16:47:28] I should add that in the book [16:47:38] :) Thanks [16:50:02] SRvSaha, can you see that? [16:50:12] yes [16:50:16] thanks :) [16:50:27] SRvSaha, see how the class name gointo [16:50:30] got into [16:50:36] SRvSaha, that is mangling the name [16:50:44] so that people do not mess around easily [16:51:09] * SRvSaha digging deeper in mangling [16:51:29] Now can anyone tell me what we call the function __init__? [16:51:44] Constructor function. [16:51:49] It is a contructor for object [16:51:56] Yes, a constructor [16:52:00] constructor [16:52:02] oops [16:52:09] I mean how to pronounce it? [16:52:15] Constructor [16:52:20] Constructor [16:52:21] double underscore init double underscore? [16:52:28] double underscore init [16:52:50] nipun, what about the double underscore at the end? [16:52:51] kushal, yes, that's how we call it [16:53:14] dunder init --- this is how Python people call it [16:53:46] Any name with double underscore in front and at the end [16:53:46] like [16:53:46] dunder call [16:53:47] never knew it [16:53:56] SRvSaha, now you know :) [16:54:00] why only one dunder [16:54:01] :) [16:54:04] ? [16:54:25] * sandeepk away for dinner [16:54:28] quite a fancy name! [16:54:45] amey, so that we don't say it again [16:54:52] people generally understand [16:55:10] OK :) [16:55:20] going back to modules [16:55:44] Python has many modules by default in the standard library, we call them part of stdlib [16:55:53] everyone do this [16:55:54] import os [16:55:56] os.uname() [16:56:15] Tell us what you see (what does that text means?) [16:56:36] Detailed info about the system and the username [16:56:54] oops not username only system related info [16:57:06] system information [16:57:35] tuple with system infomation in it. [16:57:45] Field 1 : OS , Field 2 : Server, Field 3: Kernel Version, Field 5: Architecture [16:57:51] deatils of our system [16:58:06] yes [16:58:08] ! [16:58:10] now in bash [16:58:19] ! [16:58:24] uname -a [16:58:26] system information [16:58:34] ^^^ run the above command in bash [16:59:04] yeah, same info [16:59:13] kushal, similar information [16:59:20] it is showing the same inforamtion [16:59:37] os is the module which contains many operating system related functions etc. [16:59:47] Let us go back to the shell [17:00:10] help() [17:00:12] modules [17:00:26] ^^^ the above two will give you all the install modules in your system. [17:02:06] here [17:02:21] Who all are reading this? [17:02:30] me [17:02:31] me [17:02:32] me [17:02:34] me [17:02:35] me [17:02:36] me [17:02:40] me [17:02:46] me [17:02:49] me [17:02:53] me [17:03:03] Me [17:03:04] me too [17:03:07] Me [17:03:15] me [17:03:33] reading what kushal ?? list of modules in shell [17:03:53] Someone please answer pabitra :) [17:04:18] Messages on the channel. [17:04:28] pabitra: Reading the text from kushal in IRC. [17:04:44] pabitra, kushal is just checking who are actually attending the session! [17:04:53] :D [17:05:01] i am also reading [17:05:06] oh LOL :) :D [17:05:08] Since he switched from Shell to IRC, just to check how many of ius are really attending the sesssion [17:05:38] I got confused because there was nothing in shell after modules [17:05:49] Me [17:06:03] pabitra, :) [17:06:17] one important point [17:06:19] kushal, i tried help() and module on my machine [17:06:23] getting some error [17:06:26] modules [17:06:29] pabitra, ^^ [17:07:06] even though modules are listed [17:07:19] pabitra, okay, means some module is causing pain :) [17:07:25] Anyway [17:07:39] from modulename import * [17:07:43] ^^^^ never do that [17:07:47] Never ever. [17:07:50] Please don't [17:08:01] Why? you will find with time. [17:08:06] ok [17:08:13] Either import the whole module, or do the following [17:08:22] Let us say I want to use uname from os [17:08:25] from os import uname [17:08:29] look at the shell [17:08:33] But that's a quite common practice in other programming languages like JAVA [17:08:43] * PrashantJ was about to try that as you typed it kushal [17:08:59] SRvSaha, yes, that is why I am trying to tell you, don't do that :) [17:09:45] Ok :) [17:10:40] So separate out the imports by using commas [17:12:08] ! [17:12:10] next [17:12:14] next [17:12:16] kushal: I am getting this error http://paste.fedoraproject.org/413901/47213791/ [17:12:16] next [17:12:41] * code_geek is getting the same error as SRvSaha [17:12:50] query solved:) [17:12:52] SRvSaha, what distro and python? [17:13:14] Python3 & UBUNTU 16.04LTS [17:13:26] Python 3.4 being precise [17:15:00] SRvSaha, there is a reason we ask people to use Fedora for development [17:15:12] SRvSaha, this may be part of the cause https://mail.python.org/pipermail/python-bugs-list/2002-July/012691.html [17:15:16] kushal +1 [17:15:25] I had problems with Fedora :( Graphics Issues [17:15:26] But I am not sure. [17:15:56] SRvSaha, we will have to find some solution so that you can use Fedora :) [17:16:02] next [17:16:05] next [17:16:05] SRvSaha you can ignore that ! [17:16:05] I did not get mangling [17:17:19] pabitra, even though I named the variable as __specialvalue it got mangled into _example__specialvalue [17:17:40] pabitra, can you see the difference? [17:17:49] For the log readers in the future. [17:17:56] oh ok. [17:18:01] Yes, we are talking to you :) [17:18:08] >>> class example: [17:18:08] ... def __init__(self): [17:18:08] ... self.name = "foobar" # normal name [17:18:08] ... self.__specialvalue = 10 # we don't people mess with this [17:18:11] ... self.point = 15 [17:18:14] ... [17:18:14] but I guess this is because you made it private [17:18:19] >>> e = example() [17:18:24] >>> dir(e) [17:18:26] pabitra, I did not [17:18:36] I just used __ in the front, which in turn changed the name [17:18:42] but it is not private [17:18:43] pabitra: no, that is single underscore [17:19:08] that is dunder I guess abhishekg5 [17:19:23] dunder at begining [17:19:45] kushal: Is the name mangling automatically done always when we use __ before any data member's name ? [17:20:14] kushal, if I am correct, hiding the original varaiable using __ is referred as name mangling here [17:20:33] yes I guess SRvSaha [17:21:26] pabitra, not hiding but just changing the name [17:22:01] https://en.wikipedia.org/wiki/Name_mangling#Python [17:22:06] kushal: That means anything that has dunder in the beginning will as an alias [17:22:18] the word private is just to explain. [17:22:26] As you can see that we can still use it. [17:22:27] s/as/act [17:22:54] pabitra: single underscore before a name- means you want that name to be private. Double underscores before name- means python will mangle this one. Double underscores before and after a name- means these are generally specific python methods. Just a convention [17:23:16] abhishekg5: Thanks [17:23:41] SRvSaha: :) [17:24:49] pabitra: http://stackoverflow.com/questions/1641219/does-python-have-private-variables-in-classes [17:25:07] dhritishikhar___ is now known as dhritishikhar [17:26:02] kushal: Please update the logs after 16th [17:26:16] I will :) [17:26:29] Anyway, read http://pymbook.readthedocs.io/en/latest/modules.html tonight and practice. [17:26:36] Come back with questions after that. [17:26:37] Ok :) [17:26:52] Okay (: [17:27:00] After the book chapter, read https://docs.python.org/3/tutorial/modules.html [17:27:09] ok [17:27:22] ok [17:27:27] ok [17:27:32] Roll Call [17:27:35] OK [17:27:38] Prashant Jamkhande [17:27:39] Abhishek Gupta [17:27:39] Rhitik Bhatt [17:27:39] Anushil Kumar [17:27:40] Shantanu Acharya [17:27:41] Saurav Saha [17:27:41] Amey Jain [17:27:46] Varsha R [17:27:49] sandeep kumar choudhary [17:27:49] Sudeep Mukherjee [17:27:50] Anupama Mandal [17:27:51] Rahul Bhattacharjee [17:27:55] endclass [17:27:55] [## Class Ended at Thu Aug 25 17:27:55 2016 ##]