IRC log of #novawebdev for Friday, 2024-01-26

*** jelkner has quit (Quit: Leaving)12:28
*** tboimah has quit (Quit: Leaving)13:24
*** ubuntourist has quit (None)14:01
*** ubuntourist has quit (None)14:10
ubuntouristI was on at 9:00 and no one was here. I checked again at 9:10 and no one was here.14:38
tboimahGood day ubuntourist14:41
mulbahGood morning Mr. Cole14:42
ubuntouristtboimah, mulbah, dcammue Hi.14:42
dcammueHow are you ubuntourist 14:42
mulbahHow are you Mr. Cole14:42
ubuntouristWith Python, I don't really have a lesson plan. So, I'm only on to take questions...14:43
ubuntourist...unless I think of something clever to write about. Today, I don't have any clever thoughts.14:43
ubuntouristmulbah, dcammue, tboimah I'm doing well. I hope you are all doing well.14:43
dcammueexactly Mr. Cole14:44
ubuntouristHow goes your progress with Python? Have you tried working together to make a timer for questions?14:45
tboimahwe are still working on that14:46
ubuntouristGood. I think that's the best way to learn: Find something you actually need, and fight with the code until it does what you want.14:46
mulbahMr. Cole I want you to try our ability to ask us a question in python14:47
ubuntouristmulbah, If you mean you  want me to ask you questions to see what you know, I don't really do that.14:48
dcammuecan I ask?14:49
ubuntouristmulbah, Write code. Put it in a git repository. Put it up on Codeberg.org or GitLab.com. Put in good comments. Those are the best proof that you are actually learning and applying the knowledge.14:49
ubuntouristdcammue, sure.14:49
dcammuecan python do a random selection with a words or a question?14:50
ubuntouristdcammue, yes... but... This is where being able to read the Python Library Reference manual is REALLY helpful.14:50
dcammueokay14:51
ubuntouristdcammue, random functions are not part of the built-in core functions of Python. You need to import the random library module.14:51
ubuntouristdcammue, hold a sec...14:51
ubuntouristhttps://docs.python.org/3/library/random.html#module-random14:52
dcammueThanks 14:53
ubuntouristThe Python Library Reference Manual is not the easiest thing to read, but it is INVALUABLE ! You will almost certainly need it... a lot.14:53
dcammueI save it to bookmark14:53
dcammueokay14:54
ubuntouristAlso, I was mentioning to scooper and tboimah about StackOverflow.com which is a great place to search for answers.14:54
*** mulbah has quit (Read error: Connection reset by peer)14:55
ubuntouristOn that web site, use "tags" as search terms. A "tag" is a word enclosed in brackets.14:55
ubuntouristSo I would go to https://stackoverflow.com/ and use the search terms "[python]" and "[random]" -- without quotes.14:56
dcammueokay14:56
ubuntouristThe first question that turned up when I did it just now was:14:56
ubuntourist"How can I randomly select (choose) an item from a list (get a random element)?"14:57
ubuntouristthe question has 2355 "up" votes, which means 2355 people liked the question.14:58
ubuntouristIt has 18 answers, and the best answer got 3403 likes.14:58
*** tboimah has quit (Remote host closed the connection)15:01
*** dcammue has quit (Remote host closed the connection)15:01
*** mulbah07_ has quit (Remote host closed the connection)15:01
*** dcammue has quit (None)15:03
dcammueokay /me back15:04
ubuntourist(The answers on StackOverflow are often shorter and less complete, but include examples that you can try easily.)15:04
dcammueso what the utf-8 really do in python15:05
ubuntouristdcammue, do you mean the special comment "# -*- coding:utf-8 -*-"15:06
dcammueI think is the same as encoding=utf-815:08
ubuntouristdcammue, Ah. That's different. Thanks for the clarification.15:08
ubuntourist(The special comment really doesn't do anything... except that some editors like vim and emacs read it and make use of it.15:09
ubuntouristthe encoding=utf-8 is, for me, a bit of an advanced topic but I will try to explain.15:09
ubuntouristIn the time of the dinosaurs like me, everybody  had to code the way that Americans code. That meant15:10
ubuntouristEnglish words and the American alphabet. No accented characters, no Chinese or Arabic, etc.15:11
ubuntouristYou were limited to 128 characters -- 32 control characters, 32 numbers and punctuation, 32 UPPER CASE plus a few more punctuation marks, and 32 lower case and a few more punctuation marks.15:12
ubuntouristASCII - the American Standard Code for Information Interchange15:13
ubuntourist(In your terminal window, you can type "man ascii" to see a table of ASCII values.)15:13
dcammueshould I try it now?15:14
ubuntouristdcammue, sure. Don't study it deeply right now but a quick look now is a good idea.15:15
ubuntourist128 characters is nice because it means that you only need 8 bits. One byte could hold numeric values to represent "all" of the keystroke combinations on your keyboard.15:17
ubuntouristBut many people were deeply unhappy that their own languages could not be represented. So an international committee15:18
ubuntouristinvented Unicode. Unicode is 16-bits. So now, 65,536 characters can be represented.15:19
ubuntouristAnd other specifications for Unicode mean that it can even do more than that. But it gets too technical.15:20
ubuntouristUTF-8 = Unicode Transformation Format – 8-bit15:21
dcammueokay15:22
ubuntouristYou can think of UTF-8 as a compromise: If you still really only need 128 characters, like most Americans, and most users of English,15:22
ubuntouristusing full Unicode wastes space: Every character takes up two bytes when only one is needed.15:23
ubuntouristUTF-8 is basically a way of saying that it is Unicode but it is constrained to 8 bits. It is a subset of Unicode.15:24
ubuntouristhttps://en.wikipedia.org/wiki/UTF-815:24
ubuntouristSo. encoding="UTF-8"... This is where I always need to check my understanding. jelkner can probably explain this better and more correctly.15:25
ubuntouristSo, try to do your own research but here's my understanding:15:25
ubuntouristBack when there was only 128 values, the words "character" and "byte" were almost synonymous.15:26
ubuntouristCharacters were always one byte long.15:26
ubuntouristBut when Unicode and UTF-8 were created, sometimes "character" meant 8 bits (one byte) and sometimes it meant 16 bits (two bytes).15:27
ubuntouristThat means, if you have a section of computer memory with lots of bytes, and you know it is supposed to be text, not integers or some other data,15:29
ubuntouristyou do not have a way of knowing: Is this string of 20 bytes 20 ASCII or UTF-8 letters? Or is it 10 full Unicode letters?15:30
ubuntouristBy using encoding="UTF-8" you are EXPLICITLY telling Python how to interpret a string of bytes. In this case, those 20 bytes are, in fact 20 alphanumeric characters, not 10.15:31
ubuntouristOnc again, docs.python.org can help:15:32
ubuntouristhttps://docs.python.org/3/howto/unicode.html#encodings15:32
ubuntouristI mentioned that Unicode uses 16 bits, but I also said there were modifications to allow it to include even more.15:33
dcammueyes15:35
ubuntouristAccording to the page I just mentioned, full Unicode is actually now 21-bits... So more than two bytes but not fully three.15:35
ubuntouristand it can hold 1,114,111 alphanumeric characters! Over 1 MILLION unique characters!15:36
ubuntouristRoom for all kinds of alphabets, including emoji, special math and science symbols, drawing characters, music characters...15:37
ubuntouristBut the simple answer, from a purely practical standpoint is "when you are working with Python byte strings, and the bytes are representing text,15:38
ubuntouristyou will PROBABLY almost always want to encode as UTF-8... Unlesss you start gettting a lot of contracts for web sites or applications that are not using English.15:40
ubuntouristIf you do get such contracts, you will probably have help from your business partner, unless you have in-house experts in other languages."15:40
ubuntouristACTION is done.15:40
dcammueThanks so much I have a little understanding on it15:41
ubuntouristdcammue, me too. 😉 15:42
dcammuesmall small as time goes by I will fully understand that better15:42
ubuntouristdcammue, me too. 😉 small, small. Every time I need to worry about byte strings, I need to go back to docs.python.org 15:43
ubuntouristand re-read everything about bytes and encoding="..."15:43
dcammueokay15:44
dcammuethat's it 15:44
ubuntouristIn my work, I almost never needed to work with byte strings and encoding. So, when I needed to do it, I had already forgotten how it all works.15:45
ubuntouristjelkner has a better understanding here. Possibly from working with many Spanish-speakers who need accented characters.15:45
ubuntourist(It's important stuff to learn, but Unicode and UTF-8 were not invented until I had been programming for a very long time.)15:46
ubuntouristYou will have an easier time learning it because you are starting out with the technology already being common.15:47
dcammueYeah, the brine can some times forget about what it learned in the past, but as you go back to it, it will pick it quicker than before15:47
ubuntourist(I thiink you'll have an easier time learning it. If you do, you can write a good explanation for me to read. Maybe it will be better than the Python documentation.)15:48
ubuntouristACTION doesn't have anything else to talk about and it is almost 11:00 my time...15:49
dcammueso I guess when you do re-read it you will get better understanding than before15:49
ubuntouristdcammue, yep.15:49
dcammueokay15:49
dcammueThen have a nice day ubuntourist 15:49
dcammuesee you the next Monday15:50
ubuntouristdcammue, you too. (And mulbah and tboimah.)15:50
ubuntouristSee you Monday.15:50
tboimahOkay thank for today ununtourist15:50
dcammueSweet15:50
tboimah*ubuntourist15:50
*** ubuntourist has quit (Quit: Leaving)15:51
*** dcammue has quit (Quit: Leaving)15:51
*** mulbah has quit (Quit: Leaving)16:11
*** tboimah has quit (Read error: Connection reset by peer)16:31

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