*** 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 | |
mulbah | Good morning Jeff | 11: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 | |
ubuntourist | ACTION is away for a minute | 14:02 |
*** mulbah has quit (Ping timeout: 480 seconds) | 14:02 | |
*** shmohamud has quit (Ping timeout: 480 seconds) | 14:08 | |
dcammue | Good morning ubuntourist and shmohamu_ | 14:11 |
*** shmohamu_ has quit (Remote host closed the connection) | 14:13 | |
ubuntourist | ACTION is back | 14:15 |
ubuntourist | hi sysadmin dcammue | 14:16 |
tboimah | Good day ubuntourist | 14:16 |
mulbah | Good morning Mr. Cole | 14:18 |
ubuntourist | Yesterday, 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 | |
ubuntourist | So, question 7 on jelkner's quiz: | 14:19 |
ubuntourist | I had an answer, but I thought it was rather advanced. So, I asked him about that. | 14:20 |
ubuntourist | He said that he would be happy if you could solve it as a group but that, even if you cannot, he is hoping | 14:21 |
ubuntourist | you will be able to discuss the question, and think about it. So he asked me not to reveal anything there. | 14:22 |
mulbah | okay | 14:22 |
ubuntourist | Question 5 is not hard. It may take time but once you see it, I think you will be hitting your forehead with your palm | 14:23 |
ubuntourist | and saying "Oh! How did I miss that?" | 14:23 |
mulbah | Mr. Cole I want to understand how the os modules work | 14:23 |
ubuntourist | Go through his code slowly and look for anything that is defined but not used. | 14:23 |
mulbah | it's in the code that jeff send us | 14:24 |
ubuntourist | mulbah, The os module provides objects and methods (also known as functions), and variables that are specific to | 14:25 |
ubuntourist | an operating system. | 14:25 |
ubuntourist | Hold while I get a slightly better definition. | 14:25 |
ubuntourist | First, I keep stressing the Python Library Reference manual | 14:26 |
ubuntourist | https://docs.python.org/3/ | 14:26 |
ubuntourist | https://docs.python.org/3/library/ | 14:27 |
ubuntourist | At the top right of that page, there is a link named "Modules" | 14:27 |
ubuntourist | This is the modules index, and it is where you would go to find out about the | 14:28 |
ubuntourist | modules that are automatically included with Python. (There are modules that are NOT included | 14:29 |
ubuntourist | that you must explicitly install, if you need them. And those will not be documented on this page. But | 14:29 |
ubuntourist | Python comes with many standard modules that will be listed.) | 14:30 |
mulbah | wow that is a cool link Mr. Cole | 14:30 |
ubuntourist | mulbah, on the main Python documentation page, there is a joke written under the link to the | 14:31 |
ubuntourist | Python Library Reference. It says "Keep this under your pillow" | 14:32 |
mulbah | haha | 14:33 |
ubuntourist | It is very good advice: It should be one of the first things you look at after you understand | 14:33 |
ubuntourist | the basics of Python. | 14:33 |
ubuntourist | Any Python programmer will use it a LOT! | 14:34 |
ubuntourist | So. Python is available for Linux, Mac OS X, Microsoft Windows, etc. Each operating system (os) | 14:34 |
mulbah | Mr. Cole so this link has everything of python meaning from starch to advance | 14:35 |
ubuntourist | will have different ways to do various tasks. The os module tries to handle those differences. | 14:35 |
ubuntourist | mulbah, yes. There's a tutorial for beginners, the library reference which is like having a dictionary handy, | 14:36 |
ubuntourist | a technical reference for people who are familiar with other programming languages and want to | 14:37 |
ubuntourist | know the precise breakdown and diagramming of a language, several specialized "how to" documents, etc. | 14:37 |
ubuntourist | I'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.html | 14:39 |
ubuntourist | But really the Tutorial and the Library Reference are the ones I go back to again and again. | 14:40 |
ubuntourist | mulbah, Look through the code jeff sent, right now, and tell me: Where is he using something from the os module? | 14:42 |
mulbah | alright | 14:43 |
ubuntourist | mulbah, then, take a guess as what that line does. | 14:43 |
mulbah | okay let me check | 14:43 |
mulbah | ACTION is checking | 14:43 |
ubuntourist | (This is were using "most" and the slash (/) search command are handy.) | 14:44 |
ubuntourist | (or "grep") | 14:44 |
mulbah | the os modules is use on line 59 and 66 | 14:44 |
mulbah | and I think it means clear the screen | 14:45 |
ubuntourist | mulbah, Correct! | 14:45 |
mulbah | if the is anything print out | 14:45 |
ubuntourist | And diffferent operating systems have different ways to clear the screen. | 14:45 |
mulbah | okay | 14:46 |
mulbah | Window is cls right | 14:46 |
ubuntourist | mulbah, It has been decades since I used Windows, but yes, that sounds familiar to me. | 14:46 |
mulbah | os.system('cls') on window | 14:46 |
ubuntourist | mulbah, right. | 14:47 |
mulbah | Mr. Cole I think you can use the os module to move from one file to another | 14:47 |
ubuntourist | mulbah, for details, go to the module index, look at the os module, and scroll down to "system". | 14:48 |
mulbah | and also create and delete files | 14:48 |
mulbah | Alright I will do just that | 14:48 |
ubuntourist | mulbah, again, correct. The idea of "moving" a file in Linux, is simiar to "renaming" a file in Windows. | 14:50 |
mulbah | So Mr. Cole which modules you think is cool to be practicing if you are a beginner going to another stage of python | 14:50 |
ubuntourist | Removing ("rm") is like deleting ("del"). | 14:50 |
ubuntourist | Python would like ONE way to do that so that you don't need to think "Oh, I am on Windows today, | 14:51 |
ubuntourist | so 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 |
ubuntourist | Insted, the os module provides a consistent way to talk to the operating system and say "Do it whatever way you | 14:52 |
ubuntourist | want. Just get rid of this file." | 14:52 |
ubuntourist | It tries to provide a generic way to do common tasks. And, if it cannot find a generic way, it lets | 14:53 |
ubuntourist | you ask the operating system directly, by sending a command to the shell using the system() function. | 14:53 |
ubuntourist | mulbah, you don't really "practice" with modules. | 14:54 |
ubuntourist | mulbah, you search for a module when the Python does not have the feature you are looking for. | 14:55 |
ubuntourist | mulbah, If you are doing a task and you think "Oh! I WISH Python could do..." | 14:56 |
ubuntourist | mulbah, Things like regular expressions, random choices, trigonometric functions, drawing, changing colors, etc | 14:57 |
ubuntourist | are not "normal" programming functions. So Python, by itself, will not know how to do any of thise things. But, people have | 14:58 |
ubuntourist | created modules for those. | 14:58 |
ubuntourist | You can create your own modules. | 14:59 |
ubuntourist | mulbah, remember to explain the following later to others on the team: | 15:00 |
mulbah | Alright I will | 15:00 |
ubuntourist | mulbah, remember how we were exploring environment variables in Bash? | 15:00 |
mulbah | sure | 15:01 |
ubuntourist | mulbah, and we made some of thos permanent by defining them in ~/.bashrc or ~/.profile? | 15:01 |
ubuntourist | You could create a Python file that creates variables and assigns values to them that you would like to use in lots of other | 15:02 |
ubuntourist | Python programs. And then you could import your module. | 15:03 |
ubuntourist | For example: You could create a file named "jetro.py" and put in it: | 15:03 |
ubuntourist | company = "Jetro Web Development" | 15:04 |
ubuntourist | staff = ["Mullbah K.", "Thomas B.", ... "Spencer C."] | 15:05 |
ubuntourist | address = "(whatever your address is. I don't know it.)" | 15:05 |
ubuntourist | ... | 15:05 |
ubuntourist | Then in all your programs you could add the line "import jetro" | 15:05 |
ubuntourist | Now, in all your programs you could say "print(jetro.company)" | 15:06 |
ubuntourist | or | 15:06 |
ubuntourist | for person in jetro.staff: | 15:06 |
ubuntourist | print(person) | 15:06 |
ubuntourist | That 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 |
ubuntourist | You 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 other | 15:09 |
ubuntourist | considerations. But the above example is something you could each explore individually, | 15:09 |
ubuntourist | to get ideas about why modules are useful, and begin thinking about how you might use them and create your own. | 15:10 |
dcammue | can I ask? | 15:10 |
ubuntourist | dcammue, Sure! | 15:11 |
dcammue | So if you say print(jetro.company), will it print the company name? | 15:11 |
ubuntourist | dcammue, try it now. Create jetro.py as described above, and then create another Python file that imports it. | 15:12 |
dcammue | okay | 15:12 |
ubuntourist | dcammue, Let's go to the server and try with tmate. Hold while I start a session. | 15:12 |
ubuntourist | Uh-oh !!! The server is DOWN ???? | 15:13 |
ubuntourist | students.mcssliberia.org: Name or service not known | 15:13 |
dcammue | yes, is down | 15:13 |
dcammue | according to jefff | 15:14 |
dcammue | jeff | 15: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 |
ubuntourist | Anyway, dcammue you can share your screen with tmate... | 15:16 |
dcammue | now? | 15:16 |
ubuntourist | Yep | 15:16 |
ubuntourist | ACTION waits for the link to join | 15:17 |
ubuntourist | ACTION is still waiting for dcammue to post the link | 15:19 |
dcammue | https://tmate.io/ | 15:19 |
ubuntourist | dcammue, no. when you start a session, it tells you what the ssh command for the session is. Post that. | 15:20 |
ubuntourist | dcammue, (it will be a long, ugly string of random letters and numbers. Copy and paste it into the chat.) | 15:21 |
ubuntourist | something 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 |
ubuntourist | ACTION is still waiting for dcammue to copy and paste the link... | 15:26 |
dcammue | ssh session: ssh NPqydA4ZyjqsjUjC2gM8dRJzj@lon1.tmate.io | 15:26 |
ubuntourist | dcammue, Not mk. | 15:31 |
ubuntourist | dcammue, Do you know what a file is? | 15:31 |
ubuntourist | dcammue, I see files in your directory listing that look like you created them... | 15:32 |
dcammue | yes I know file | 15:32 |
dcammue | it is found with in a folder | 15:33 |
ubuntourist | dcammue, How were exm.py, g.py leay.py, st.py, study.py, try.py created? | 15:33 |
ubuntourist | dcammue, You have lots of files. CSS files, HTML files, Python files. Do what you did and make a jetro.py file. | 15:35 |
dcammue | is through the editor | 15:38 |
dcammue | i created those file from thonny | 15:38 |
ubuntourist | dcammue, right. When someone says "create a file" or "make a file" usually, you want to start an editor. | 15:39 |
ubuntourist | dcammue, Ah. | 15:39 |
ubuntourist | dcammue, that explains a lot. | 15:39 |
ubuntourist | dcammue, I was thinking that you knew an editor you could use in the terminal. | 15:39 |
dcammue | but I really don | 15:39 |
dcammue | don't understand the terminal yet | 15:40 |
ubuntourist | dcammue, the terminal is going to be very, very, VERY important. | 15:40 |
dcammue | okay | 15:41 |
ubuntourist | dcammue, there are several editors that you can use in the terminal. Jeff will want you to use vi (or vim). | 15:41 |
ubuntourist | dcammue, I don't care what editor you use. (I do not use vi and vim.) | 15:41 |
ubuntourist | dcammue, but for today, we will use a very simple editor. Do not become too in love with it, because | 15:42 |
ubuntourist | lateer you will want a better one. | 15:42 |
ubuntourist | Type "nano jetro.py" | 15:42 |
ubuntourist | nano tries to be helpful by showing you commands at the bottom of the screen. Don't worry about those yet. | 15:44 |
ubuntourist | dcammue, now scroll up in this chat window to find the three lines to add to the jetro.py file. | 15:44 |
ubuntourist | dcammue, It does not have to be perfect. Do not be too concerned about small typos. | 15:46 |
dcammue | ok | 15:47 |
ubuntourist | fkoikoi, you can follow along at ssh NPqydA4ZyjqsjUjC2gM8dRJzj@lon1.tmate.io | 15:47 |
fkoikoi | okay | 15:47 |
fkoikoi | already there Mr. Cole | 15:48 |
ubuntourist | dcammue, OK. Now, nano is helping by showing Ctrl-X (^X) for Exit at the bottom. | 15:50 |
ubuntourist | dcammue, No. | 15:50 |
ubuntourist | jetro.py cannot import jetro | 15:50 |
ubuntourist | Take that line out. | 15:50 |
ubuntourist | ^X --- Ctrl-X to Exit | 15:50 |
ubuntourist | Then just hit ENTER twice | 15:50 |
ubuntourist | jetro,py | 15:51 |
ubuntourist | N | 15:51 |
ubuntourist | jetro.py | 15:51 |
ubuntourist | ls | 15:52 |
ubuntourist | no | 15:52 |
ubuntourist | You deleted the "y" from the end of the file name and created jetro.p. | 15:52 |
ubuntourist | Now you will need to rename it. | 15:53 |
ubuntourist | mv jetro.p jetro.py | 15:53 |
ubuntourist | dcammue, mv jetro.p jetro.py | 15:54 |
ubuntourist | OK. | 15:54 |
ubuntourist | NOW, python3 | 15:54 |
ubuntourist | import jetro | 15:55 |
ubuntourist | Now try the print statement you asked me about... | 15:55 |
*** mulbah has quit (Remote host closed the connection) | 15:56 | |
ubuntourist | dcammue, so the answer to your question is "Yes! It does print that!" | 15:57 |
dcammue | good | 15:57 |
dcammue | Thanks | 15:57 |
ubuntourist | So, if jetro.py was on the server, and was in a diretory that all of the members could access, | 15:58 |
ubuntourist | then everyone could just start all of their python programs with "import jetro" | 15:59 |
ubuntourist | and they would have a full list of the membership, web site, co-op name, address, phone numbers | 15:59 |
ubuntourist | and whatever other things you want to add to the file. No one would need to type that in. | 16:00 |
ubuntourist | And if members join or quit, someone can edit jetro.py to update the membership list. | 16:00 |
ubuntourist | Or if you get a better address, or add phone numbers, or whatever. | 16:01 |
ubuntourist | It's 11:00 my time. Time to quit for the day, but | 16:01 |
ubuntourist | dcammue, you could experiment by creating another python file and starting THAT file with import jetro. | 16:02 |
dcammue | In the same terminal right? | 16:03 |
ubuntourist | It should work the same way -- IF it is in the same directory! Your new file needs to know where to find jetro.py | 16:03 |
ubuntourist | dcammue, you could do it in the terminal or if you want to do it with thonny that's okay... for now. | 16:03 |
ubuntourist | dcammue, just be sure that the file ends up in the same directory as jetro.py and do try to learn basic editing in the terminal | 16:04 |
dcammue | okay | 16:05 |
ubuntourist | dcammue, There are situations where you will need to edit on the server. You do not want to be | 16:05 |
dcammue | Thanks | 16:05 |
dcammue | see you Friday | 16:05 |
ubuntourist | dcammue, stuck where you must download the file from the server, edit in thonny, and upload again. That | 16:05 |
ubuntourist | dcammue, is a big waste of time. | 16:06 |
ubuntourist | And 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 |
ubuntourist | dcammue, fkoikoi, scooper, tboimah See you all Friday. | 16:08 |
tboimah | Okay thank for today | 16:08 |
dcammue | okay | 16:09 |
ubuntourist | tboimah, share with people about envrionment variablaes, ~/.bashrc, and ~/.profile, | 16:09 |
tboimah | Okay | 16:09 |
tboimah | I will do that | 16:09 |
ubuntourist | tboimah, because that is a lot like what this jetro.py file does for Python. | 16:09 |
tboimah | oaky | 16:10 |
tboimah | *okay | 16: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/!