IRC log of #novawebdev for Monday, 2024-02-05

*** shmohamud has quit (Read error: Connection reset by peer)01:40
*** shmohamud has quit (Remote host closed the connection)01:52
*** shmohamud has quit (Ping timeout: 480 seconds)02:47
*** shmohamud has quit (Ping timeout: 480 seconds)03:58
*** shmohamud has quit (Ping timeout: 480 seconds)04:09
*** shmohamud has quit (Remote host closed the connection)05:57
*** shmohamud has quit (Ping timeout: 480 seconds)07:37
*** shmohamud has quit (Remote host closed the connection)10:40
*** tboimah has quit (Ping timeout: 480 seconds)10:43
*** shmohamud has quit (Ping timeout: 480 seconds)10:50
mulbahGood morning Jeff11:52
*** jelkner has quit (Quit: Leaving)12:05
*** mulbah has quit (Ping timeout: 480 seconds)12:14
*** tboimah has quit (Ping timeout: 480 seconds)12:14
*** tboimah has quit (Ping timeout: 480 seconds)14:02
ubuntouristACTION is away for a minute14:02
*** mulbah has quit (Ping timeout: 480 seconds)14:02
*** shmohamud has quit (Ping timeout: 480 seconds)14:08
dcammueGood morning ubuntourist and shmohamu_14:11
*** shmohamu_ has quit (Remote host closed the connection)14:13
ubuntouristACTION is back14:15
ubuntouristhi sysadmin dcammue 14:16
tboimahGood day ubuntourist14:16
mulbahGood morning Mr. Cole14:18
ubuntouristYesterday, I went on an 8-mile walk. I was in the habit of walking 12 miles for many years, but then became lazy and cut back to four. So today my bones are feeling the effect of yesterday...14:19
*** mulbah has quit (Remote host closed the connection)14:19
ubuntouristSo, question 7 on jelkner's quiz:14:19
ubuntouristI had an answer, but I thought it was rather advanced. So, I asked him about that.14:20
ubuntouristHe said that he would be happy if you could solve it as a group but that, even if you cannot, he is hoping14:21
ubuntouristyou will be able to discuss the question, and think about it. So he asked me not to reveal anything there.14:22
mulbahokay14:22
ubuntouristQuestion 5 is not hard. It may take time but once you see it, I think you will be hitting your forehead with your palm14:23
ubuntouristand saying "Oh! How did I miss that?"14:23
mulbahMr. Cole I want to understand how the os modules work14:23
ubuntouristGo through his code slowly and look for anything that is defined but not used.14:23
mulbahit's in the code that jeff send us14:24
ubuntouristmulbah, The os module provides objects and methods (also known as functions), and variables that are specific to 14:25
ubuntouristan operating system.14:25
ubuntouristHold while I get a slightly better definition.14:25
ubuntouristFirst, I keep stressing the Python Library Reference manual14:26
ubuntouristhttps://docs.python.org/3/14:26
ubuntouristhttps://docs.python.org/3/library/14:27
ubuntouristAt the top right of that page, there is a link named "Modules"14:27
ubuntouristThis is the modules index, and it is where you would go to find out about the14:28
ubuntouristmodules that are automatically included with Python. (There are modules that are NOT included14:29
ubuntouristthat you must explicitly install, if you need them. And those will not be documented on this page. But14:29
ubuntouristPython comes with many standard modules that will be listed.)14:30
mulbahwow that is a cool link Mr. Cole14:30
ubuntouristmulbah, on the main Python documentation page, there is a joke written under the link to the 14:31
ubuntouristPython Library Reference. It says "Keep this under your pillow"14:32
mulbahhaha14:33
ubuntouristIt is very good advice: It should be one of the first things you look at after you understand 14:33
ubuntouristthe basics of Python.14:33
ubuntouristAny Python programmer will use it a LOT!14:34
ubuntouristSo. Python is available for Linux, Mac OS X, Microsoft Windows, etc. Each operating system (os)14:34
mulbahMr. Cole so this link has everything of python meaning from starch to advance14:35
ubuntouristwill have different ways to do various tasks. The os module tries to handle those differences.14:35
ubuntouristmulbah, yes. There's a tutorial for beginners, the library reference which is like having a dictionary handy,14:36
ubuntourista technical reference for people who are familiar with other programming languages and want to 14:37
ubuntouristknow the precise breakdown and diagramming of a language, several specialized "how to" documents, etc.14:37
ubuntouristI've always found the tutorial and the library reference to be the most useful.14:38
ubuntourist(Some of the "how to" are pretty good too. I think there is one on regular expressions that I used a lot.14:38
ubuntourist...yup: The Regular Expression HOWTO - https://docs.python.org/3.12/howto/regex.html14:39
ubuntouristBut really  the Tutorial and the Library Reference are the ones I go back to again and again.14:40
ubuntouristmulbah, Look through the code jeff sent, right now, and tell me: Where is he using something from the os module?14:42
mulbahalright14:43
ubuntouristmulbah, then, take a guess as what that line does.14:43
mulbahokay let me check 14:43
mulbahACTION is checking14:43
ubuntourist(This is were using "most" and the slash (/) search command are handy.)14:44
ubuntourist(or "grep")14:44
mulbahthe os modules is use on line 59 and 6614:44
mulbahand I think it means clear the screen 14:45
ubuntouristmulbah, Correct!14:45
mulbahif the is anything print out14:45
ubuntouristAnd diffferent operating systems have different ways to clear the screen.14:45
mulbahokay14:46
mulbahWindow is cls right14:46
ubuntouristmulbah, It has been decades since I used Windows, but yes, that sounds familiar to me.14:46
mulbahos.system('cls') on window 14:46
ubuntouristmulbah, right.14:47
mulbahMr. Cole I think you can use the os module to move from one file to another14:47
ubuntouristmulbah, for details, go to the module index, look at the os module, and scroll down to "system".14:48
mulbahand also create and delete files14:48
mulbahAlright I will do just that14:48
ubuntouristmulbah, again, correct. The idea of "moving" a file in Linux, is simiar to "renaming" a file in Windows.14:50
mulbahSo Mr. Cole which modules you think is cool to be practicing if you are a beginner going to another stage of python14:50
ubuntouristRemoving ("rm") is like deleting ("del").14:50
ubuntouristPython would like ONE way to do that so that you don't need to think "Oh, I am on Windows today,14:51
ubuntouristso I sould use 'del'. Tomorrow I will be on a Linux computer and will need to remember to change my code to 'rm'."14:51
ubuntouristInsted, the os module provides a consistent way to talk to the operating system and say "Do it whatever way you14:52
ubuntouristwant. Just get rid of this file."14:52
ubuntouristIt tries to provide a generic way to do common tasks. And, if it cannot find a generic way, it lets14:53
ubuntouristyou ask the operating system directly, by sending a command to the shell using the system() function.14:53
ubuntouristmulbah, you don't really "practice" with modules.14:54
ubuntouristmulbah, you search for a module when the Python does not have the feature you are looking for.14:55
ubuntouristmulbah, If you are doing a task and you think "Oh! I WISH Python could do..."14:56
ubuntouristmulbah, Things like regular expressions, random choices, trigonometric functions, drawing, changing colors, etc14:57
ubuntouristare not "normal" programming functions. So Python, by itself, will not know how to do any of thise things. But, people have14:58
ubuntouristcreated modules for those.14:58
ubuntouristYou can create your own modules.14:59
ubuntouristmulbah, remember to explain the following later to others on the team:15:00
mulbahAlright I will15:00
ubuntouristmulbah, remember how we were exploring environment variables in Bash?15:00
mulbahsure15:01
ubuntouristmulbah, and we made some of thos permanent by defining them in ~/.bashrc or ~/.profile?15:01
ubuntouristYou could create a Python file that creates variables and assigns values to them that you would like to use in lots of other15:02
ubuntouristPython programs. And then you could import your module.15:03
ubuntouristFor example: You could create a file named "jetro.py" and put in it:15:03
ubuntouristcompany = "Jetro Web Development"15:04
ubuntouriststaff = ["Mullbah K.", "Thomas B.", ... "Spencer C."]15:05
ubuntouristaddress = "(whatever your address is. I don't know it.)"15:05
ubuntourist...15:05
ubuntouristThen in all your programs you could add the line "import jetro"15:05
ubuntouristNow, in all your programs you could say "print(jetro.company)"15:06
ubuntouristor 15:06
ubuntouristfor person in jetro.staff:15:06
ubuntourist     print(person)15:06
ubuntouristThat is a VERY simple example of a module. (To be a true module it will need to be a little fancier, but it is the basic idea.)15:08
ubuntouristYou would also need to put jetro.py in a location where everyone could use it. So, not in your personal directory. And there are a few other15:09
ubuntouristconsiderations. But the above example is something you could each explore individually,15:09
ubuntouristto get ideas about why modules are useful, and begin thinking about how you might use them and create your own.15:10
dcammuecan I ask?15:10
ubuntouristdcammue, Sure!15:11
dcammueSo if you say print(jetro.company), will it print the company name?15:11
ubuntouristdcammue, try it now. Create jetro.py as described above, and then create another Python file that imports it.15:12
dcammueokay15:12
ubuntouristdcammue, Let's go to the server and try with tmate. Hold while I start a session.15:12
ubuntouristUh-oh !!! The server is DOWN ????15:13
ubuntouriststudents.mcssliberia.org: Name or service not known15:13
dcammueyes, is down15:13
dcammueaccording to jefff15:14
dcammuejeff15:14
ubuntourist(Jeff tells me this is where I need to be careful, because I just want to utter a vulgar curse.)15:14
ubuntourist(Bad manners when there are students, and maybe parents reading this.)15:15
ubuntouristAnyway, dcammue you can share your screen with tmate...15:16
dcammuenow?15:16
ubuntouristYep15:16
ubuntouristACTION waits for the link to join15:17
ubuntouristACTION is still waiting for dcammue to post the link15:19
dcammuehttps://tmate.io/15:19
ubuntouristdcammue, no. when you start a session, it tells you what the ssh command for the session is. Post that.15:20
ubuntouristdcammue, (it will be a long, ugly string of random letters and numbers. Copy and paste it into the chat.)15:21
ubuntouristsomething like "ssh 6sree33qrfcsaasr45vnzkxxxgglidtyytdmhbodsdprttt@..."15:22
ubuntourist(It is different each time you create a shared session. So, I cannot predict what it will be.)15:23
ubuntouristACTION is still waiting for dcammue to copy and paste the link...15:26
dcammuessh session: ssh NPqydA4ZyjqsjUjC2gM8dRJzj@lon1.tmate.io15:26
ubuntouristdcammue, Not mk.15:31
ubuntouristdcammue, Do you know what a file is?15:31
ubuntouristdcammue, I see files in your directory listing that look like you created them...15:32
dcammueyes I know file15:32
dcammueit is found with in a folder15:33
ubuntouristdcammue, How were exm.py, g.py leay.py, st.py, study.py, try.py created?15:33
ubuntouristdcammue, You have lots of files. CSS files, HTML files, Python files. Do what you did and make a jetro.py file.15:35
dcammueis through the editor15:38
dcammuei created those file from thonny15:38
ubuntouristdcammue, right. When someone says "create a file" or "make a file" usually, you want to start an editor.15:39
ubuntouristdcammue, Ah.15:39
ubuntouristdcammue, that explains a lot.15:39
ubuntouristdcammue, I was thinking that you knew an editor you could use in the terminal.15:39
dcammuebut I really don15:39
dcammuedon't understand the terminal yet15:40
ubuntouristdcammue, the terminal is going to be very, very, VERY important. 15:40
dcammueokay15:41
ubuntouristdcammue, there are several editors that you can use in the terminal. Jeff will want you to use vi (or vim).15:41
ubuntouristdcammue, I don't care what editor you use. (I do not use vi and vim.)15:41
ubuntouristdcammue, but for today, we will use a very simple editor. Do not become too in love with it, because 15:42
ubuntouristlateer you will want a better one.15:42
ubuntouristType "nano jetro.py"15:42
ubuntouristnano tries to be helpful by showing you commands at the bottom of the screen. Don't worry about those yet.15:44
ubuntouristdcammue, now scroll up in this chat window to find the three lines to add to the jetro.py file.15:44
ubuntouristdcammue, It does not have to be perfect.  Do not be too concerned about small typos.15:46
dcammueok15:47
ubuntouristfkoikoi, you can follow along at ssh NPqydA4ZyjqsjUjC2gM8dRJzj@lon1.tmate.io15:47
fkoikoiokay15:47
fkoikoialready there Mr. Cole15:48
ubuntouristdcammue, OK. Now, nano is helping by showing Ctrl-X (^X) for Exit at the bottom.15:50
ubuntouristdcammue, No.15:50
ubuntouristjetro.py cannot import jetro15:50
ubuntouristTake that line out.15:50
ubuntourist^X   --- Ctrl-X to Exit15:50
ubuntouristThen just hit ENTER twice15:50
ubuntouristjetro,py15:51
ubuntouristN15:51
ubuntouristjetro.py15:51
ubuntouristls15:52
ubuntouristno15:52
ubuntouristYou deleted the "y" from the end of the file name and created jetro.p.15:52
ubuntouristNow you will need to rename it.15:53
ubuntouristmv jetro.p jetro.py15:53
ubuntouristdcammue,  mv jetro.p jetro.py15:54
ubuntouristOK.15:54
ubuntouristNOW, python315:54
ubuntouristimport jetro15:55
ubuntouristNow try the print statement you asked me about...15:55
*** mulbah has quit (Remote host closed the connection)15:56
ubuntouristdcammue, so the answer to your question is "Yes! It does print that!"   15:57
dcammuegood 15:57
dcammueThanks15:57
ubuntouristSo, if jetro.py was on the server, and was in a diretory that all of the members could access,15:58
ubuntouristthen everyone could just start all of their python programs with "import jetro"15:59
ubuntouristand they would have a full list of the membership, web site, co-op name, address, phone numbers15:59
ubuntouristand whatever other things you want to add to the file. No one would need to type that in.16:00
ubuntouristAnd if members join or quit, someone can edit jetro.py to update the membership list.16:00
ubuntouristOr if you get a better address, or add phone numbers, or whatever.16:01
ubuntouristIt's 11:00 my time. Time to quit for the day, but16:01
ubuntouristdcammue, you could experiment by creating another python file and starting THAT file with import jetro.16:02
dcammueIn the same terminal right?16:03
ubuntouristIt should work the same way -- IF it is in the same directory!  Your new file needs to know where to find jetro.py16:03
ubuntouristdcammue, you could do it in the terminal or if you want to do it with thonny that's okay... for now.16:03
ubuntouristdcammue, just be sure that the file ends up in the same directory as jetro.py and do try to learn basic editing in the terminal16:04
dcammueokay16:05
ubuntouristdcammue, There are situations where you will need to edit on the server. You do not want to be 16:05
dcammueThanks16:05
dcammuesee you Friday16:05
ubuntouristdcammue, stuck where you must download the file from the server, edit in thonny, and upload again. That16:05
ubuntouristdcammue, is a big waste of time.16:06
ubuntouristAnd your thonny will not find files on the server. thonny limits you to files on your computer.16:06
ubuntourist(It's a nice editor for learning Python and learning concepts of editing, but ultimately, you will want other editors.)16:07
ubuntouristdcammue, fkoikoi, scooper, tboimah See you all Friday.16:08
tboimahOkay thank for today16:08
dcammueokay16:09
ubuntouristtboimah, share with people about envrionment variablaes, ~/.bashrc, and ~/.profile,16:09
tboimahOkay16:09
tboimahI will do that16:09
ubuntouristtboimah, because that is a lot like what this jetro.py file does for Python.16:09
tboimahoaky16:10
tboimah*okay16:10
*** ubuntourist has quit (Quit: Leaving)16:10
*** fkoikoi has quit (Quit: Leaving)16:12
*** scooper has quit (Quit: Leaving)16:32
*** tboimah has quit (Remote host closed the connection)16:40
*** dcammue has quit (Quit: Leaving)16:43
*** shmohamud has quit (Ping timeout: 480 seconds)17:01
*** shmohamud has quit (Ping timeout: 480 seconds)18:01
*** shmohamud has quit (Ping timeout: 480 seconds)19:32
*** shmohamud has quit (Ping timeout: 480 seconds)21:01
*** shmohamud has quit (Ping timeout: 480 seconds)22:31

Generated by irclog2html.py 2.17.3 by Marius Gedminas - find it at https://mg.pov.lt/irclog2html/!