1 00:00:13,120 --> 00:00:18,880 hello pycon welcome back uh you're back 2 00:00:16,880 --> 00:00:22,000 with the education track 3 00:00:18,880 --> 00:00:25,439 and uh this talk is a pre-recorded talk 4 00:00:22,000 --> 00:00:28,800 but with a special super exciting twist 5 00:00:25,439 --> 00:00:31,119 um the fantastic andre roberge will be 6 00:00:28,800 --> 00:00:34,399 joining us uh for his talk it doesn't 7 00:00:31,119 --> 00:00:38,320 work uh and he will also be joining us 8 00:00:34,399 --> 00:00:39,920 in the chat um on the stream yard chat 9 00:00:38,320 --> 00:00:41,840 you will be able to interact with him 10 00:00:39,920 --> 00:00:44,640 during the talk and 11 00:00:41,840 --> 00:00:48,640 he'll join us live afterwards 12 00:00:44,640 --> 00:00:51,039 um for some questions so 13 00:00:48,640 --> 00:00:52,719 without further ado uh i should 14 00:00:51,039 --> 00:00:55,120 introduce him he's not here i'm 15 00:00:52,719 --> 00:00:57,280 forgetting my things okay so andre first 16 00:00:55,120 --> 00:00:59,840 learned programming by taking a course 17 00:00:57,280 --> 00:01:03,359 in fortran when he was a teenager but he 18 00:00:59,840 --> 00:01:05,040 never had much use for it uh in 2004 19 00:01:03,359 --> 00:01:07,040 while in his 40s he decided to pick up 20 00:01:05,040 --> 00:01:08,640 programming as a hobby and a creative 21 00:01:07,040 --> 00:01:10,880 outlet to distract him from his day job 22 00:01:08,640 --> 00:01:12,880 that sounds fantastic i love it 23 00:01:10,880 --> 00:01:14,960 since then he mostly focused on creating 24 00:01:12,880 --> 00:01:17,119 programs and programming environments 25 00:01:14,960 --> 00:01:18,479 intended to help beginners learn his 26 00:01:17,119 --> 00:01:21,920 favorite hobby 27 00:01:18,479 --> 00:01:24,720 these include uh rupple reeborgs world 28 00:01:21,920 --> 00:01:27,600 avant pai and a few others with the 29 00:01:24,720 --> 00:01:28,400 latest being friendly 30 00:01:27,600 --> 00:01:29,520 so 31 00:01:28,400 --> 00:01:32,320 i will 32 00:01:29,520 --> 00:01:33,920 pass over to the pre-recorded talk um 33 00:01:32,320 --> 00:01:36,479 think up some questions put them in the 34 00:01:33,920 --> 00:01:39,200 chat put them in the questions chat 35 00:01:36,479 --> 00:01:42,799 and we'll answer them all throughout and 36 00:01:39,200 --> 00:01:42,799 after thank you so much 37 00:01:44,399 --> 00:01:48,880 welcome to it doesn't work 38 00:01:46,880 --> 00:01:53,360 a talk given as part of the education 39 00:01:48,880 --> 00:01:55,759 track of pycon australia 2021 40 00:01:53,360 --> 00:01:58,320 my name is andre robert joining you 41 00:01:55,759 --> 00:02:01,200 today from canada where i live and have 42 00:01:58,320 --> 00:02:01,200 fun with python 43 00:02:01,439 --> 00:02:07,040 note that many slides shown during the 44 00:02:03,600 --> 00:02:08,560 stock include tiny xkcd cartoon panels 45 00:02:07,040 --> 00:02:10,399 too small for you to read during the 46 00:02:08,560 --> 00:02:12,160 presentation 47 00:02:10,399 --> 00:02:13,520 these are intended to provide additional 48 00:02:12,160 --> 00:02:16,640 entertainment to people that have 49 00:02:13,520 --> 00:02:16,640 downloaded the slides 50 00:02:18,000 --> 00:02:21,840 since this is the education track i'm 51 00:02:20,160 --> 00:02:23,840 assuming that you have taught or planned 52 00:02:21,840 --> 00:02:27,840 to teach python to someone else that i 53 00:02:23,840 --> 00:02:27,840 will refer to as your students 54 00:02:28,319 --> 00:02:34,080 your students have python including idle 55 00:02:31,440 --> 00:02:36,480 installed on a computer 56 00:02:34,080 --> 00:02:38,800 you decide to introduce them to python 57 00:02:36,480 --> 00:02:41,760 using the turtle module starting with a 58 00:02:38,800 --> 00:02:41,760 complete example 59 00:02:42,640 --> 00:02:46,400 you show them how to run a program 60 00:02:48,000 --> 00:02:52,160 success a square has been drawn 61 00:02:53,040 --> 00:02:58,560 your students copied a code from your 62 00:02:54,720 --> 00:02:58,560 example and attempt to run it 63 00:02:59,599 --> 00:03:02,560 it doesn't work 64 00:03:03,040 --> 00:03:08,319 they see virtual red ink in their 65 00:03:05,200 --> 00:03:10,480 experience red ink is not a good thing 66 00:03:08,319 --> 00:03:13,040 they take a closer look at the content 67 00:03:10,480 --> 00:03:15,760 and see a lot of unknown jargon 68 00:03:13,040 --> 00:03:20,000 traceback attribute error partially 69 00:03:15,760 --> 00:03:21,599 initialized module circular import etc 70 00:03:20,000 --> 00:03:23,599 at this point your students might get 71 00:03:21,599 --> 00:03:25,120 discouraged thinking that programming is 72 00:03:23,599 --> 00:03:27,360 not for them 73 00:03:25,120 --> 00:03:29,840 they feel inadequate and might just want 74 00:03:27,360 --> 00:03:29,840 to give up 75 00:03:30,879 --> 00:03:36,319 could this be made more user-friendly 76 00:03:34,080 --> 00:03:38,080 before we see if this is possible 77 00:03:36,319 --> 00:03:42,080 let's review the type of information we 78 00:03:38,080 --> 00:03:42,080 can get from a normal python traceback 79 00:03:42,959 --> 00:03:47,760 we can see where in the code the error 80 00:03:44,879 --> 00:03:49,519 occurred 81 00:03:47,760 --> 00:03:51,920 we can see what type of exception was 82 00:03:49,519 --> 00:03:51,920 raised 83 00:03:52,480 --> 00:03:57,120 the message gives us an idea as to why 84 00:03:54,480 --> 00:03:59,040 the exception was raised 85 00:03:57,120 --> 00:04:01,360 of course it requires some experience to 86 00:03:59,040 --> 00:04:02,720 be able to decipher such tracebacks 87 00:04:01,360 --> 00:04:06,480 something that we cannot expect 88 00:04:02,720 --> 00:04:10,159 beginners to be able to do on their own 89 00:04:06,480 --> 00:04:10,159 what if there existed a better way 90 00:04:10,640 --> 00:04:15,599 on the left we have a normal traceback 91 00:04:13,599 --> 00:04:18,000 what if we could have like what is shown 92 00:04:15,599 --> 00:04:20,160 on the right side a modified version 93 00:04:18,000 --> 00:04:22,000 with shorter lines and some black and 94 00:04:20,160 --> 00:04:26,080 blue in addition to the red 95 00:04:22,000 --> 00:04:26,080 let's zoom in to this modified traceback 96 00:04:27,520 --> 00:04:31,199 this is the modified traceback 97 00:04:29,520 --> 00:04:33,280 student might perhaps recognize more 98 00:04:31,199 --> 00:04:35,360 easily the text in black as being the 99 00:04:33,280 --> 00:04:36,800 code they wrote 100 00:04:35,360 --> 00:04:39,600 at the bottom 101 00:04:36,800 --> 00:04:42,000 except for the word module 102 00:04:39,600 --> 00:04:44,080 what if a nearly jargon-free easy to 103 00:04:42,000 --> 00:04:46,160 understand sentence was added giving 104 00:04:44,080 --> 00:04:48,400 them a hint of what might be the source 105 00:04:46,160 --> 00:04:50,240 of their problem 106 00:04:48,400 --> 00:04:53,280 did you give your program the same name 107 00:04:50,240 --> 00:04:53,280 as a python module 108 00:04:54,639 --> 00:04:58,320 when using idle we have access to a 109 00:04:56,560 --> 00:05:00,720 python interpreter after running a 110 00:04:58,320 --> 00:05:00,720 program 111 00:05:00,960 --> 00:05:05,440 if students didn't know about python 112 00:05:02,479 --> 00:05:07,759 exceptions what if asking what could 113 00:05:05,440 --> 00:05:11,840 reveal the meaning of the exception in 114 00:05:07,759 --> 00:05:11,840 this case here an attribute error 115 00:05:12,160 --> 00:05:16,320 what if asking where would show the 116 00:05:14,080 --> 00:05:19,199 location of the error more explicitly 117 00:05:16,320 --> 00:05:21,199 than a traditional traceback would 118 00:05:19,199 --> 00:05:23,280 we see the part in the line highlighted 119 00:05:21,199 --> 00:05:26,000 in red indicating the exact location of 120 00:05:23,280 --> 00:05:27,759 the problematic code 121 00:05:26,000 --> 00:05:29,840 at the bottom we see a reference to 122 00:05:27,759 --> 00:05:32,080 turtle.py 123 00:05:29,840 --> 00:05:34,560 before continuing with this example 124 00:05:32,080 --> 00:05:38,280 let me show you a similar where output 125 00:05:34,560 --> 00:05:38,280 from a different example 126 00:05:38,880 --> 00:05:45,280 here at the bottom instead of turtle.py 127 00:05:41,600 --> 00:05:46,720 we see pythonlib turtle.py 128 00:05:45,280 --> 00:05:49,199 this tells us that the code is from 129 00:05:46,720 --> 00:05:50,800 python standards library and not code 130 00:05:49,199 --> 00:05:52,320 written by a student 131 00:05:50,800 --> 00:05:53,759 unlike what we saw with the previous 132 00:05:52,320 --> 00:05:57,039 example 133 00:05:53,759 --> 00:05:57,039 let's go back to that example 134 00:05:57,919 --> 00:06:02,000 what if asking why gave the student a 135 00:06:00,319 --> 00:06:03,280 more complete explanation as to what 136 00:06:02,000 --> 00:06:06,000 might have caused the problem they have 137 00:06:03,280 --> 00:06:06,880 encountered 138 00:06:06,000 --> 00:06:08,720 and 139 00:06:06,880 --> 00:06:12,240 if this was not enough what if there 140 00:06:08,720 --> 00:06:15,919 existed yet one more option 141 00:06:12,240 --> 00:06:18,400 what if typing www as a function 142 00:06:15,919 --> 00:06:20,400 used python's web browser module to do 143 00:06:18,400 --> 00:06:24,479 an internet search with the error 144 00:06:20,400 --> 00:06:24,479 message used as a search string 145 00:06:25,680 --> 00:06:30,160 all of this is possible using friendly 146 00:06:27,919 --> 00:06:34,240 or friendly traceback 147 00:06:30,160 --> 00:06:37,120 let's have a look at a second example 148 00:06:34,240 --> 00:06:39,120 during pycon australia 2018 much fun was 149 00:06:37,120 --> 00:06:41,120 had talking about something called a 150 00:06:39,120 --> 00:06:43,039 flip-flop rater 151 00:06:41,120 --> 00:06:45,440 the code shown on this slide was used in 152 00:06:43,039 --> 00:06:47,440 an example 153 00:06:45,440 --> 00:06:49,120 this code includes a text 154 00:06:47,440 --> 00:06:50,720 i have had a great day with this large 155 00:06:49,120 --> 00:06:52,720 boy mr bubble 156 00:06:50,720 --> 00:06:57,759 you may also know him as masjid chunky 157 00:06:52,720 --> 00:06:57,759 bubble or mr loves to eat the food bobo 158 00:06:58,319 --> 00:07:02,319 here i show the result when i attempt to 159 00:07:00,160 --> 00:07:04,880 run this example using friendly in a 160 00:07:02,319 --> 00:07:08,080 terminal instead of with an idle 161 00:07:04,880 --> 00:07:10,240 i get a trace back with a name error 162 00:07:08,080 --> 00:07:13,759 the text in white at the bottom is a 163 00:07:10,240 --> 00:07:13,759 hint headed by friendly 164 00:07:14,639 --> 00:07:19,599 asking why gives us a fuller explanation 165 00:07:16,800 --> 00:07:21,360 as to what might have caused the problem 166 00:07:19,599 --> 00:07:24,720 it suggests that we might have forgotten 167 00:07:21,360 --> 00:07:26,639 to install the module from pipi 168 00:07:24,720 --> 00:07:29,039 note that friendly also subscribes to 169 00:07:26,639 --> 00:07:31,840 the notion that using the flips operator 170 00:07:29,039 --> 00:07:31,840 is a bad idea 171 00:07:32,639 --> 00:07:36,639 when i watch the talks about the flips 172 00:07:34,240 --> 00:07:38,479 operator i notice the use of the phrase 173 00:07:36,639 --> 00:07:40,160 music 174 00:07:38,479 --> 00:07:42,000 clearly this one example was an 175 00:07:40,160 --> 00:07:45,840 indication that there must be a thriving 176 00:07:42,000 --> 00:07:45,840 french-speaking community in australia 177 00:07:45,919 --> 00:07:50,000 assuming they are watching this talk 178 00:07:47,680 --> 00:07:51,680 those french-speaking pathonistas should 179 00:07:50,000 --> 00:07:53,199 be pleased to know that friendly can 180 00:07:51,680 --> 00:07:55,520 give them information in their preferred 181 00:07:53,199 --> 00:07:57,120 language 182 00:07:55,520 --> 00:07:59,840 this is the end of a rather long 183 00:07:57,120 --> 00:07:59,840 introduction 184 00:08:00,560 --> 00:08:03,759 for the rest of this talk i'd like to 185 00:08:02,080 --> 00:08:05,759 give you a brief historical overview of 186 00:08:03,759 --> 00:08:07,520 the evolution of friendly initially 187 00:08:05,759 --> 00:08:10,879 known as friendly traceback 188 00:08:07,520 --> 00:08:10,879 showing a few more examples 189 00:08:11,039 --> 00:08:14,879 then i will attempt to justify the 190 00:08:12,479 --> 00:08:16,639 approach i use in developing friendly by 191 00:08:14,879 --> 00:08:19,039 using some work from experts in the 192 00:08:16,639 --> 00:08:19,039 field 193 00:08:20,400 --> 00:08:25,039 the purpose of this talk is to motivate 194 00:08:22,240 --> 00:08:27,520 you to use friendly with your students 195 00:08:25,039 --> 00:08:29,360 my hope is that in return you will 196 00:08:27,520 --> 00:08:32,400 provide me with some feedback so that i 197 00:08:29,360 --> 00:08:32,400 can make it even better 198 00:08:33,120 --> 00:08:36,479 when i created friendly traceback my 199 00:08:34,800 --> 00:08:38,080 initial idea was to create a tool that 200 00:08:36,479 --> 00:08:39,680 could help students decipher normal 201 00:08:38,080 --> 00:08:41,200 python tracebacks 202 00:08:39,680 --> 00:08:43,279 so that they could eventually learn to 203 00:08:41,200 --> 00:08:45,279 extract the what where and why on their 204 00:08:43,279 --> 00:08:47,120 own 205 00:08:45,279 --> 00:08:49,600 initially i thought of simply taking the 206 00:08:47,120 --> 00:08:51,519 message included in the traceback 207 00:08:49,600 --> 00:08:53,200 reformulating it so that students could 208 00:08:51,519 --> 00:08:55,519 make better sense of it 209 00:08:53,200 --> 00:08:57,760 and make it possible to translate this 210 00:08:55,519 --> 00:09:00,560 reform loaded message into languages 211 00:08:57,760 --> 00:09:00,560 other than english 212 00:09:01,040 --> 00:09:04,000 so 213 00:09:01,839 --> 00:09:09,080 given an error like what is shown name 214 00:09:04,000 --> 00:09:09,080 error name misu is not defined 215 00:09:09,120 --> 00:09:13,760 friendly trace backwards to provide all 216 00:09:10,880 --> 00:09:15,440 the information shown on this slide 217 00:09:13,760 --> 00:09:17,360 what is a name error 218 00:09:15,440 --> 00:09:18,800 an explanation that might be useful if 219 00:09:17,360 --> 00:09:19,839 such an error is encountered for the 220 00:09:18,800 --> 00:09:21,920 first time 221 00:09:19,839 --> 00:09:23,839 but might become superfluous after a 222 00:09:21,920 --> 00:09:26,000 while 223 00:09:23,839 --> 00:09:29,279 why this error might have occurred 224 00:09:26,000 --> 00:09:30,800 and where exactly in the code 225 00:09:29,279 --> 00:09:33,519 this is the information provided by 226 00:09:30,800 --> 00:09:37,839 friendly traceback with overlaid boxes 227 00:09:33,519 --> 00:09:37,839 on the slide to make it easier to parse 228 00:09:38,000 --> 00:09:42,000 of course in reality 229 00:09:39,600 --> 00:09:44,959 these boxes are not present and we see a 230 00:09:42,000 --> 00:09:44,959 big chunk of text 231 00:09:45,839 --> 00:09:50,080 here instead of using friendly traceback 232 00:09:47,920 --> 00:09:52,000 i used friendly which does some 233 00:09:50,080 --> 00:09:53,680 additional formatting including adding 234 00:09:52,000 --> 00:09:55,519 colors 235 00:09:53,680 --> 00:09:58,480 these added colors should make it easier 236 00:09:55,519 --> 00:10:00,560 to parse the information 237 00:09:58,480 --> 00:10:02,640 still having all information shown at 238 00:10:00,560 --> 00:10:06,959 once especially with more complex 239 00:10:02,640 --> 00:10:09,360 examples can lead to a huge wall of text 240 00:10:06,959 --> 00:10:11,279 this led me to add the functions what 241 00:10:09,360 --> 00:10:13,440 where and why that can be used 242 00:10:11,279 --> 00:10:17,640 interactively to obtain only parts of 243 00:10:13,440 --> 00:10:17,640 the information when required 244 00:10:18,880 --> 00:10:23,279 for example why 245 00:10:21,040 --> 00:10:25,120 in your program no object with the name 246 00:10:23,279 --> 00:10:28,320 must you exist 247 00:10:25,120 --> 00:10:30,160 i have no additional information for you 248 00:10:28,320 --> 00:10:32,480 originally from the traceback did not 249 00:10:30,160 --> 00:10:33,200 add i have no additional information for 250 00:10:32,480 --> 00:10:35,680 you 251 00:10:33,200 --> 00:10:36,720 since that was always the case 252 00:10:35,680 --> 00:10:38,640 however 253 00:10:36,720 --> 00:10:41,680 that has since changed as i will show in 254 00:10:38,640 --> 00:10:41,680 a different example later 255 00:10:42,880 --> 00:10:46,480 of course this approach of explaining 256 00:10:44,640 --> 00:10:48,560 what a given exception means and what 257 00:10:46,480 --> 00:10:50,800 might have caused the error simply based 258 00:10:48,560 --> 00:10:52,880 on the text provided by python 259 00:10:50,800 --> 00:10:56,079 is not exactly helpful when the message 260 00:10:52,880 --> 00:10:58,399 is simply invalid syntax 261 00:10:56,079 --> 00:11:00,399 so a little over two years ago i figured 262 00:10:58,399 --> 00:11:02,320 out a way to automatically analyze a few 263 00:11:00,399 --> 00:11:04,240 invalid syntax cases 264 00:11:02,320 --> 00:11:08,399 and wrote a blog post inviting other 265 00:11:04,240 --> 00:11:08,399 people to suggest additional examples 266 00:11:08,800 --> 00:11:13,120 it did not take long for the first 267 00:11:10,320 --> 00:11:15,279 suggestion to come in 268 00:11:13,120 --> 00:11:17,920 over time a few more suggestions were 269 00:11:15,279 --> 00:11:19,760 made encouraging me to pursue further on 270 00:11:17,920 --> 00:11:22,480 my own in attempt to analyze more and 271 00:11:19,760 --> 00:11:22,480 more cases 272 00:11:23,760 --> 00:11:28,640 here's an example done while using new 273 00:11:26,720 --> 00:11:31,519 arguably the most beginner-friendly 274 00:11:28,640 --> 00:11:33,680 python editor that exists 275 00:11:31,519 --> 00:11:36,880 i first start by importing everything 276 00:11:33,680 --> 00:11:39,440 from friendly.new 277 00:11:36,880 --> 00:11:40,640 after importing the turtle module i try 278 00:11:39,440 --> 00:11:43,839 to call pen 279 00:11:40,640 --> 00:11:43,839 which results in a traceback 280 00:11:44,320 --> 00:11:47,839 friendly sand at the bottom includes two 281 00:11:46,480 --> 00:11:49,920 suggestions 282 00:11:47,839 --> 00:11:53,120 either a typo was made and i meant to 283 00:11:49,920 --> 00:11:55,920 write the built-in lan instead of pen 284 00:11:53,120 --> 00:11:58,399 or since span is an attribute of turtle 285 00:11:55,920 --> 00:12:00,240 a module that was previously imported 286 00:11:58,399 --> 00:12:02,639 perhaps a reference to that module is 287 00:12:00,240 --> 00:12:02,639 missing 288 00:12:04,240 --> 00:12:08,079 mu has different themes 289 00:12:06,399 --> 00:12:09,120 switching to the knight theme changes 290 00:12:08,079 --> 00:12:10,880 the color 291 00:12:09,120 --> 00:12:13,279 and the output provided by friendly no 292 00:12:10,880 --> 00:12:15,360 micro blends in 293 00:12:13,279 --> 00:12:18,560 when using friendly with mu in a night 294 00:12:15,360 --> 00:12:20,160 theme a student or teacher can type in 295 00:12:18,560 --> 00:12:22,000 knight as a function 296 00:12:20,160 --> 00:12:24,639 so that the information displayed 297 00:12:22,000 --> 00:12:26,560 afterwards by friendly matches the theme 298 00:12:24,639 --> 00:12:27,839 used by mu 299 00:12:26,560 --> 00:12:30,079 asking y 300 00:12:27,839 --> 00:12:32,000 results in a more detailed explanation 301 00:12:30,079 --> 00:12:35,200 than that given by the hint added at the 302 00:12:32,000 --> 00:12:37,200 bottom of the traceback by friendly 303 00:12:35,200 --> 00:12:39,360 in the previous example you might have 304 00:12:37,200 --> 00:12:41,440 noticed that i use a star import which 305 00:12:39,360 --> 00:12:43,040 is generally frowned upon usually for 306 00:12:41,440 --> 00:12:44,639 good reasons 307 00:12:43,040 --> 00:12:47,040 i don't have enough time in this talk to 308 00:12:44,639 --> 00:12:47,920 explain why i nonetheless suggest to do 309 00:12:47,040 --> 00:12:49,120 so 310 00:12:47,920 --> 00:12:50,959 i invite you to consult the 311 00:12:49,120 --> 00:12:52,959 documentation for the detailed 312 00:12:50,959 --> 00:12:55,600 explanation and for suggested 313 00:12:52,959 --> 00:12:57,200 alternatives specific to friendly 314 00:12:55,600 --> 00:12:59,680 such as the one i will show in the next 315 00:12:57,200 --> 00:12:59,680 example 316 00:13:00,959 --> 00:13:05,279 here's an example of a normal traceback 317 00:13:03,360 --> 00:13:07,360 created when using the latest version of 318 00:13:05,279 --> 00:13:09,839 jupiter lab 319 00:13:07,360 --> 00:13:12,399 the details of the code are important 320 00:13:09,839 --> 00:13:14,079 however i want to draw your attention to 321 00:13:12,399 --> 00:13:16,240 the weird file name we see in a 322 00:13:14,079 --> 00:13:18,000 traceback 323 00:13:16,240 --> 00:13:21,240 how is a student supposed to make sense 324 00:13:18,000 --> 00:13:21,240 of this information 325 00:13:22,000 --> 00:13:25,839 let's use friendly 326 00:13:23,600 --> 00:13:27,839 this time by importing a single object 327 00:13:25,839 --> 00:13:31,440 from friendly.jupiter 328 00:13:27,839 --> 00:13:33,200 as an alternative to doing a star import 329 00:13:31,440 --> 00:13:34,800 while it is not needed i adjusted the 330 00:13:33,200 --> 00:13:36,639 friendliest theme to better match the 331 00:13:34,800 --> 00:13:38,240 jupiter light theme 332 00:13:36,639 --> 00:13:40,079 i also set the width of friendly's 333 00:13:38,240 --> 00:13:43,199 output so that it made for better screen 334 00:13:40,079 --> 00:13:43,199 captures for the stock 335 00:13:44,560 --> 00:13:49,760 i now run the same code as before 336 00:13:47,440 --> 00:13:52,320 notice how instead of some weird file 337 00:13:49,760 --> 00:13:55,279 names the traceback include references 338 00:13:52,320 --> 00:13:59,199 to code blocks which is the terminology 339 00:13:55,279 --> 00:13:59,199 used in jupiter's documentation 340 00:13:59,920 --> 00:14:03,600 if i want to know the cause of the 341 00:14:01,279 --> 00:14:06,000 problem according to friendly this time 342 00:14:03,600 --> 00:14:08,959 i cannot simply type the function y 343 00:14:06,000 --> 00:14:11,279 since i did not use a star import 344 00:14:08,959 --> 00:14:15,800 instead i can use the y method of the 345 00:14:11,279 --> 00:14:15,800 friendly object to achieve the same goal 346 00:14:16,399 --> 00:14:20,000 i've mentioned friendly and friendly 347 00:14:18,320 --> 00:14:21,360 trace pack 348 00:14:20,000 --> 00:14:23,760 initially the project was called 349 00:14:21,360 --> 00:14:26,160 friendly traceback and later renamed 350 00:14:23,760 --> 00:14:26,160 friendly 351 00:14:26,560 --> 00:14:30,959 at the end of june of this year the 352 00:14:28,399 --> 00:14:32,880 project was split into two projects move 353 00:14:30,959 --> 00:14:35,040 from my personal github site to a new 354 00:14:32,880 --> 00:14:36,800 friendly traceback organization i 355 00:14:35,040 --> 00:14:38,720 created 356 00:14:36,800 --> 00:14:41,199 friendly traceback does the analysis 357 00:14:38,720 --> 00:14:43,839 required to provide answers to the what 358 00:14:41,199 --> 00:14:46,160 where and why i mentioned before 359 00:14:43,839 --> 00:14:48,480 friendly takes care of providing the 360 00:14:46,160 --> 00:14:49,839 required formatting in a variety of 361 00:14:48,480 --> 00:14:51,920 environments 362 00:14:49,839 --> 00:14:55,120 interpreters using terminals editors 363 00:14:51,920 --> 00:14:58,240 such as idle and mu ipython console 364 00:14:55,120 --> 00:15:00,639 jupyter notebooks etc 365 00:14:58,240 --> 00:15:02,560 it builds upon friendly traceback 366 00:15:00,639 --> 00:15:05,199 friendly is also the program most users 367 00:15:02,560 --> 00:15:07,040 should install 368 00:15:05,199 --> 00:15:09,760 some third party projects 369 00:15:07,040 --> 00:15:11,199 such as the websites hack in science and 370 00:15:09,760 --> 00:15:12,959 future quarter 371 00:15:11,199 --> 00:15:17,199 use information provided by friendly 372 00:15:12,959 --> 00:15:17,199 traceback and do their own formatting 373 00:15:18,720 --> 00:15:22,720 the split was done on the request of one 374 00:15:20,399 --> 00:15:24,160 of those third-party users who found the 375 00:15:22,720 --> 00:15:25,920 additional dependencies to be 376 00:15:24,160 --> 00:15:28,240 detrimental to the performance of their 377 00:15:25,920 --> 00:15:28,240 site 378 00:15:29,199 --> 00:15:32,480 the approach i use in developing 379 00:15:30,480 --> 00:15:33,440 friendly is to add new examples one at a 380 00:15:32,480 --> 00:15:35,120 time 381 00:15:33,440 --> 00:15:37,360 trying to find a way to automatically 382 00:15:35,120 --> 00:15:39,199 identify the relevant information 383 00:15:37,360 --> 00:15:41,839 and providing explanations that can be 384 00:15:39,199 --> 00:15:41,839 easily understood 385 00:15:42,079 --> 00:15:45,519 currently there are more than 300 386 00:15:43,759 --> 00:15:47,839 individual cases for which friendly can 387 00:15:45,519 --> 00:15:50,800 provide an explanation 388 00:15:47,839 --> 00:15:55,839 those cases were either some of my own 389 00:15:50,800 --> 00:15:55,839 or very often suggested by other users 390 00:15:57,120 --> 00:16:01,040 while i keep adding new examples i 391 00:15:58,800 --> 00:16:03,279 rarely go back and revisit explanations 392 00:16:01,040 --> 00:16:05,040 given in older examples 393 00:16:03,279 --> 00:16:07,279 so i encourage all of you to look at the 394 00:16:05,040 --> 00:16:09,040 examples which are all available in the 395 00:16:07,279 --> 00:16:11,040 documentation site 396 00:16:09,040 --> 00:16:13,440 and invite you to either suggest new 397 00:16:11,040 --> 00:16:16,240 examples or better explanations for the 398 00:16:13,440 --> 00:16:16,240 existing ones 399 00:16:17,440 --> 00:16:22,480 when using an interactive interpreter it 400 00:16:19,839 --> 00:16:25,199 is unfortunately very easy to make typos 401 00:16:22,480 --> 00:16:27,360 causing spurious race-backs 402 00:16:25,199 --> 00:16:30,160 can an interactive python interpreter be 403 00:16:27,360 --> 00:16:30,160 user-friendly 404 00:16:30,800 --> 00:16:34,880 here i have some code that caused a 405 00:16:32,320 --> 00:16:34,880 traceback 406 00:16:35,279 --> 00:16:39,279 i want to find out why 407 00:16:37,600 --> 00:16:41,600 but i made a typo in writing the 408 00:16:39,279 --> 00:16:43,279 function name at the top 409 00:16:41,600 --> 00:16:46,480 this should be easy to correct given the 410 00:16:43,279 --> 00:16:49,040 hint provided by friendly 411 00:16:46,480 --> 00:16:50,880 i typed it correctly this time 412 00:16:49,040 --> 00:16:52,160 but it does not give me the explanation 413 00:16:50,880 --> 00:16:53,759 i needed 414 00:16:52,160 --> 00:16:56,560 it told me that i made a mistake in 415 00:16:53,759 --> 00:16:58,160 typing out y which i already knew and 416 00:16:56,560 --> 00:17:00,720 has nothing to do with the first 417 00:16:58,160 --> 00:17:00,720 traceback 418 00:17:01,199 --> 00:17:07,280 by using the history function i can view 419 00:17:03,519 --> 00:17:07,280 all the exceptions raised so far 420 00:17:07,839 --> 00:17:13,120 i can go back in history 421 00:17:09,600 --> 00:17:13,120 thus erasing the latest mistake 422 00:17:13,360 --> 00:17:16,799 i can now ask why 423 00:17:15,280 --> 00:17:20,880 and get an explanation for the first 424 00:17:16,799 --> 00:17:20,880 traceback as i wanted in the first place 425 00:17:22,880 --> 00:17:26,240 since recording a first version of this 426 00:17:24,400 --> 00:17:28,079 talk i've added a new way to use 427 00:17:26,240 --> 00:17:30,160 friendly within jupiter notebooks and 428 00:17:28,079 --> 00:17:32,400 similar environments 429 00:17:30,160 --> 00:17:34,960 instead of having to type what where and 430 00:17:32,400 --> 00:17:36,720 why the user can simply click on buttons 431 00:17:34,960 --> 00:17:37,919 to show or hide the corresponding 432 00:17:36,720 --> 00:17:40,480 explanation 433 00:17:37,919 --> 00:17:43,600 thus eliminating typo related problems 434 00:17:40,480 --> 00:17:43,600 in these environments 435 00:17:45,280 --> 00:17:49,520 in trying to improve friendly there's 436 00:17:47,039 --> 00:17:52,880 always a question at the back of my mind 437 00:17:49,520 --> 00:17:54,799 am i making the right choices 438 00:17:52,880 --> 00:17:57,200 so far i have had some feedback from 439 00:17:54,799 --> 00:17:58,799 individual users who are advanced python 440 00:17:57,200 --> 00:18:00,320 programmers 441 00:17:58,799 --> 00:18:04,400 but there has been no systematic 442 00:18:00,320 --> 00:18:04,400 evaluation done with actual beginners 443 00:18:05,280 --> 00:18:09,200 in the absence of such studies i 444 00:18:07,280 --> 00:18:11,600 recently read a paper on the topic after 445 00:18:09,200 --> 00:18:13,679 i saw a link to it on twitter 446 00:18:11,600 --> 00:18:15,280 on designing programming error messages 447 00:18:13,679 --> 00:18:19,919 for novices 448 00:18:15,280 --> 00:18:19,919 readability and its constituent factors 449 00:18:21,760 --> 00:18:25,360 while reading this paper i noted that 450 00:18:23,440 --> 00:18:27,679 the problems associated with bad error 451 00:18:25,360 --> 00:18:31,520 messages have been discussed for a few 452 00:18:27,679 --> 00:18:31,520 decades without being solved 453 00:18:32,080 --> 00:18:36,320 according to that paper there are two 454 00:18:34,240 --> 00:18:37,760 important factors for readability of 455 00:18:36,320 --> 00:18:42,320 error messages 456 00:18:37,760 --> 00:18:43,919 message length and use of jargon 457 00:18:42,320 --> 00:18:46,400 ideally one should 458 00:18:43,919 --> 00:18:49,679 remove jargon in acronyms 459 00:18:46,400 --> 00:18:52,080 write messages in complete sentences 460 00:18:49,679 --> 00:18:54,559 use simple vocabulary 461 00:18:52,080 --> 00:18:58,320 use an economy of words 462 00:18:54,559 --> 00:18:58,320 so complete but short sentences 463 00:18:59,039 --> 00:19:03,840 the paper focused on readability which 464 00:19:01,679 --> 00:19:07,120 the authors deem to be more fundamental 465 00:19:03,840 --> 00:19:07,120 than usability 466 00:19:07,360 --> 00:19:12,080 by usability they mean how useful is the 467 00:19:09,919 --> 00:19:15,200 information provided in finding a 468 00:19:12,080 --> 00:19:15,200 solution to the problem 469 00:19:15,840 --> 00:19:20,240 the others are groups of students 470 00:19:17,360 --> 00:19:22,000 evaluating error messages from java c 471 00:19:20,240 --> 00:19:24,160 and python 472 00:19:22,000 --> 00:19:26,559 i expected the results to be that error 473 00:19:24,160 --> 00:19:28,880 messages from java were two verbose 474 00:19:26,559 --> 00:19:32,880 those from c to cryptic 475 00:19:28,880 --> 00:19:32,880 and those from python just right 476 00:19:32,960 --> 00:19:36,799 i was wrong 477 00:19:34,400 --> 00:19:39,600 error messages from python were rated as 478 00:19:36,799 --> 00:19:41,280 the worst of the three 479 00:19:39,600 --> 00:19:44,080 let's consider why that might be the 480 00:19:41,280 --> 00:19:47,120 case using the first example shown at 481 00:19:44,080 --> 00:19:47,120 the beginning of this talk 482 00:19:48,080 --> 00:19:53,039 prior to version 3.8 483 00:19:50,400 --> 00:19:54,480 the error message provided by python was 484 00:19:53,039 --> 00:19:59,120 relatively short 485 00:19:54,480 --> 00:19:59,120 module turtle has no attribute forward 486 00:20:00,240 --> 00:20:03,760 this message did not contain any 487 00:20:02,080 --> 00:20:06,760 additional information about the actual 488 00:20:03,760 --> 00:20:06,760 cause 489 00:20:07,360 --> 00:20:11,200 then more information was added 490 00:20:09,679 --> 00:20:12,400 potentially useful to more advanced 491 00:20:11,200 --> 00:20:14,240 programmers 492 00:20:12,400 --> 00:20:17,440 but full of jargon that cannot be 493 00:20:14,240 --> 00:20:17,440 understood by beginners 494 00:20:18,720 --> 00:20:22,559 however when using friendly with any 495 00:20:21,120 --> 00:20:24,880 python version 496 00:20:22,559 --> 00:20:25,840 an additional hint is provided which 497 00:20:24,880 --> 00:20:29,600 should be 498 00:20:25,840 --> 00:20:29,600 more easily understood by beginners 499 00:20:30,400 --> 00:20:34,240 to be fair i must note that some recent 500 00:20:32,559 --> 00:20:36,240 improvement for python where some 501 00:20:34,240 --> 00:20:38,960 invalid syntax messages have been 502 00:20:36,240 --> 00:20:40,159 replaced by something more useful 503 00:20:38,960 --> 00:20:41,679 for example 504 00:20:40,159 --> 00:20:43,039 errors due to forgetting to close a 505 00:20:41,679 --> 00:20:45,280 parenthesis 506 00:20:43,039 --> 00:20:48,280 are now identified correctly in python 507 00:20:45,280 --> 00:20:48,280 3.10 508 00:20:48,960 --> 00:20:52,559 here's the same example run with 509 00:20:50,559 --> 00:20:54,320 friendly which gives the same correct 510 00:20:52,559 --> 00:20:55,679 explanation for all supported python 511 00:20:54,320 --> 00:20:58,480 versions 512 00:20:55,679 --> 00:21:01,720 even if you only get an invalid syntax 513 00:20:58,480 --> 00:21:01,720 error message 514 00:21:03,360 --> 00:21:06,240 python caters to all kinds of 515 00:21:05,039 --> 00:21:08,559 programmers 516 00:21:06,240 --> 00:21:10,480 from beginners just learning the basics 517 00:21:08,559 --> 00:21:12,559 to advanced programmers using python in 518 00:21:10,480 --> 00:21:14,640 their daily job 519 00:21:12,559 --> 00:21:16,480 when it comes to error messages 520 00:21:14,640 --> 00:21:18,880 it would seem that python seeks a middle 521 00:21:16,480 --> 00:21:21,360 ground and occasionally uses jargon not 522 00:21:18,880 --> 00:21:23,919 accessible to beginners 523 00:21:21,360 --> 00:21:26,880 by contrast friendly attempts to cater 524 00:21:23,919 --> 00:21:26,880 to such beginners 525 00:21:27,679 --> 00:21:31,760 let's have a look at a different example 526 00:21:29,840 --> 00:21:34,640 where python gives an error message that 527 00:21:31,760 --> 00:21:39,360 is rather obscure for beginners 528 00:21:34,640 --> 00:21:39,360 none type object is not subscriptable 529 00:21:40,480 --> 00:21:44,480 using friendly and asking why 530 00:21:42,640 --> 00:21:46,880 gives us an explanation 531 00:21:44,480 --> 00:21:49,039 but no actual clue as to what the object 532 00:21:46,880 --> 00:21:50,799 causing the problem is 533 00:21:49,039 --> 00:21:54,159 the note at the bottom explain what the 534 00:21:50,799 --> 00:21:54,159 non-type jargon means 535 00:21:56,080 --> 00:22:01,600 asking where gives us more information 536 00:21:59,840 --> 00:22:03,520 friendly traceback always attempts to 537 00:22:01,600 --> 00:22:04,960 isolate the part of the code that causes 538 00:22:03,520 --> 00:22:08,480 problems and 539 00:22:04,960 --> 00:22:11,039 identify the value of each object 540 00:22:08,480 --> 00:22:12,880 here we have a dict x containing other 541 00:22:11,039 --> 00:22:15,440 python digs 542 00:22:12,880 --> 00:22:18,480 at the very bottom we can see that x 543 00:22:15,440 --> 00:22:20,480 bracket 42 bracket 1 bracket 2 has the 544 00:22:18,480 --> 00:22:22,880 value of none which is the cause of the 545 00:22:20,480 --> 00:22:22,880 problem 546 00:22:24,240 --> 00:22:28,960 this almost concludes this introductory 547 00:22:26,080 --> 00:22:30,880 talk to friendly and friendly traceback 548 00:22:28,960 --> 00:22:32,000 to find out more you could use a search 549 00:22:30,880 --> 00:22:33,520 engine to find out friendly's 550 00:22:32,000 --> 00:22:35,679 documentation 551 00:22:33,520 --> 00:22:38,960 but there's a better way 552 00:22:35,679 --> 00:22:38,960 first install friendly 553 00:22:39,600 --> 00:22:42,880 start the friendly console 554 00:22:43,280 --> 00:22:47,760 typing in friendly provides some basic 555 00:22:45,440 --> 00:22:47,760 help 556 00:22:50,159 --> 00:22:54,640 to find out even more type www as a 557 00:22:53,360 --> 00:22:56,080 function 558 00:22:54,640 --> 00:22:58,559 assuming you write this function call 559 00:22:56,080 --> 00:23:00,320 without making any typo no exception 560 00:22:58,559 --> 00:23:02,480 will have been raised and instead of 561 00:23:00,320 --> 00:23:03,600 doing an internet search that function 562 00:23:02,480 --> 00:23:06,400 will take you to friendly's 563 00:23:03,600 --> 00:23:08,400 documentation 564 00:23:06,400 --> 00:23:10,480 as in addition to unit tests i record 565 00:23:08,400 --> 00:23:11,919 almost all the example tracebacks for 566 00:23:10,480 --> 00:23:13,760 different python versions in a 567 00:23:11,919 --> 00:23:15,280 documentation 568 00:23:13,760 --> 00:23:17,760 this occasionally helps to spot 569 00:23:15,280 --> 00:23:19,520 regressions it is also useful to review 570 00:23:17,760 --> 00:23:21,600 the explanation given 571 00:23:19,520 --> 00:23:24,960 i encourage you to do so and make 572 00:23:21,600 --> 00:23:26,880 suggestions to improve them 573 00:23:24,960 --> 00:23:30,159 you might also come across some notices 574 00:23:26,880 --> 00:23:32,000 about design choices 575 00:23:30,159 --> 00:23:33,919 these are two record choices i make for 576 00:23:32,000 --> 00:23:36,320 friendly traceback inviting you to 577 00:23:33,919 --> 00:23:38,240 comment about their suitability perhaps 578 00:23:36,320 --> 00:23:40,799 there are better ways to present the 579 00:23:38,240 --> 00:23:40,799 information 580 00:23:41,679 --> 00:23:46,000 of course using pip to install packages 581 00:23:43,840 --> 00:23:48,480 such as friendly is often something that 582 00:23:46,000 --> 00:23:51,840 beginners find difficult ideally there 583 00:23:48,480 --> 00:23:51,840 should be a better way 584 00:23:52,559 --> 00:23:56,559 perhaps friendly will be installed by 585 00:23:54,159 --> 00:23:59,039 default in a future version of new as 586 00:23:56,559 --> 00:24:03,720 has been recorded on mu's github repo by 587 00:23:59,039 --> 00:24:03,720 nicholas tallarvy muse creator 588 00:24:04,320 --> 00:24:08,320 one of the main ipython and jupiter 589 00:24:06,240 --> 00:24:10,320 developer has expressed support for 590 00:24:08,320 --> 00:24:12,799 enabling friendly by default if it is 591 00:24:10,320 --> 00:24:12,799 installed 592 00:24:14,640 --> 00:24:18,640 in conclusion 593 00:24:16,000 --> 00:24:21,440 i invite you to try out friendly 594 00:24:18,640 --> 00:24:23,360 read the documentation and give feedback 595 00:24:21,440 --> 00:24:25,440 so that it can hopefully make friendly 596 00:24:23,360 --> 00:24:27,919 even more useful for you and for your 597 00:24:25,440 --> 00:24:27,919 students 598 00:24:28,880 --> 00:24:32,559 and of course i will come any question 599 00:24:31,279 --> 00:24:34,960 you might have 600 00:24:32,559 --> 00:24:34,960 thank you 601 00:24:37,760 --> 00:24:43,120 um immediately after lunch we have 602 00:24:40,000 --> 00:24:45,200 a fantastic talk by steven and allison 603 00:24:43,120 --> 00:24:48,159 on at the turn of the tide teaching 604 00:24:45,200 --> 00:24:51,200 python in real time at scale so make 605 00:24:48,159 --> 00:24:54,720 sure you all join us for that one in the 606 00:24:51,200 --> 00:24:56,960 meantime andre thank you once again uh 607 00:24:54,720 --> 00:24:58,640 have a fantastic lunch everyone and 608 00:24:56,960 --> 00:25:01,840 we'll see you soon 609 00:24:58,640 --> 00:25:01,840 cheers thank you