WEBVTT 1 00:00:01.960 --> 00:00:06.170 one of the simplest modules in the Python standard libraries is web browser 2 00:00:06.170 --> 00:00:10.260 which doesn't actually implement a web browser despite the name but what it does it is allows 3 00:00:10.260 --> 00:00:14.710 you to launch one of your installed browsers and navigate to a particular url 4 00:00:14.710 --> 00:00:19.800 so this example is going to do just we are going to launch using your 5 00:00:19.800 --> 00:00:23.390 computers default browser the system's default browser and navigate to 6 00:00:23.390 --> 00:00:28.430 the python home page so type.... to 7 00:00:28.430 --> 00:00:41.769 import that library and type... and type in the URL so.... 8 00:00:41.769 --> 00:00:48.870 and if I right click that and click on run and by the way I've created a new project called web 9 00:00:48.870 --> 00:00:54.620 browser and a new Python file called browser.py so I run browser you can see 10 00:00:54.620 --> 00:00:59.460 it automatically open the browser and the and the browser opens up Python.org 11 00:00:59.460 --> 00:01:03.909 so you saw previously how the help function can display a url giving more help on a 12 00:01:03.909 --> 00:01:09.030 module or a function so help itself has actually as it turns out user's Web 13 00:01:09.030 --> 00:01:12.829 browser to perform that functionality 14 00:01:12.829 --> 00:01:16.649 because this is such a simple module provides what we think is a 15 00:01:16.649 --> 00:01:20.700 good example for looking at the documentation and 16 00:01:20.700 --> 00:01:24.310 learning how to read it so we're not gonna cover every single module on the 17 00:01:24.310 --> 00:01:28.360 standard library but by the time you finish this section we should be able to 18 00:01:28.360 --> 00:01:32.210 work out how to use any other modules that we don't specifically cover by sort 19 00:01:32.210 --> 00:01:35.950 of referring to the documentation so gonna go to the documentation for web 20 00:01:35.950 --> 00:01:41.079 browser explaining how it is set out and what are the various terms in the 21 00:01:41.079 --> 00:01:44.530 documentation actually mean now the aim here again is to provide you with the 22 00:01:44.530 --> 00:01:48.590 knowledge you need to use a documentation for any other modules so 23 00:01:48.590 --> 00:01:52.369 whether that part of the standard library or for that matter additional modules that you 24 00:01:52.369 --> 00:01:57.960 may install on your computer and as part of you will get a general idea of the style and the 25 00:01:57.960 --> 00:02:01.149 level of detail required for useful documentation and that will help when it 26 00:02:01.149 --> 00:02:04.960 when the time comes to document your own functions and 27 00:02:04.960 --> 00:02:08.910 modules which is another important aspect of programming let's go ahead and 28 00:02:08.910 --> 00:02:13.920 just make a modification to our program we got our web browser opened so what we gonna do 29 00:02:13.920 --> 00:02:19.560 is add another line now we are going to type.... and put web browser in brackets like so 30 00:02:19.560 --> 00:02:22.900 we're gonna run it which will open the browser and that's navigating you 31 00:02:22.900 --> 00:02:26.650 can see its open another tab in the browser and that's worked find but if we now tab 32 00:02:26.650 --> 00:02:31.350 back to our program on the right hand side we actually got some 33 00:02:31.350 --> 00:02:34.550 documentation showing up and that's what's come up as a result of calling 34 00:02:34.550 --> 00:02:39.459 helped or putting the code line 5 help web browser being name of the standard 35 00:02:39.459 --> 00:02:44.560 library module so getting help web browser itself provides a link to this 36 00:02:44.560 --> 00:02:50.180 link and I'm going to click on that and copy it rather and go back to our browser so we can see it in 37 00:02:50.180 --> 00:02:57.650 there its actually going to their you can see the link is... 38 00:02:57.650 --> 00:03:02.459 ....and that can be slightly different to using a 39 00:03:02.459 --> 00:03:07.010 different version of Python but let us go through that page anyway and explain any 40 00:03:07.010 --> 00:03:10.590 details that we haven't explained before that you may not come across before 41 00:03:10.590 --> 00:03:15.769 incidentally if we go back to our code there is the link that I was talking and this 42 00:03:15.769 --> 00:03:21.590 one is actually 3.5 the other one is 3.4 but it does depend on the version and you got a good overview of 43 00:03:21.590 --> 00:03:24.690 what this module is all about 44 00:03:24.690 --> 00:03:28.049 obviously interfaces for launching remotely controlling web browser and 45 00:03:28.049 --> 00:03:33.110 its got the various functions and so on so go back to the browser and you can see 46 00:03:33.110 --> 00:03:37.060 it's telling us their that it provides a high-level interface to allow displaying a web 47 00:03:37.060 --> 00:03:40.950 based documents to users and most circumstances simply calling the open 48 00:03:40.950 --> 00:03:44.190 function which already done from this module will do the right thing and you 49 00:03:44.190 --> 00:03:49.320 can see that in our case it successfully worked and when I use the term 50 00:03:49.320 --> 00:03:52.910 high level interface what it is saying is no need to understand such things as 51 00:03:52.910 --> 00:03:57.109 transport protocols or networking really your just calling open and everything else 52 00:03:57.109 --> 00:04:00.700 happens magically so that's really what it is saying in there now this is a 53 00:04:00.700 --> 00:04:05.140 standard way of displaying documentation for the various modules in Python 54 00:04:05.140 --> 00:04:09.970 and the descriptions generally within going to describe any special situations 55 00:04:09.970 --> 00:04:14.120 that you should be aware of in other words any behavior that may vary from 56 00:04:14.120 --> 00:04:17.850 one operating system to the next and also some usage instructions if the module 57 00:04:17.850 --> 00:04:22.229 can be called in various ways and you can see on the screen for the web browser module will 58 00:04:22.229 --> 00:04:26.669 warned that the program will block on UNIX systems if a graphical browser is not 59 00:04:26.669 --> 00:04:31.410 available so that might seem odd but at one time all browsers were texts base and 60 00:04:31.410 --> 00:04:36.620 I remember myself being introduced to the internet in 1992 and I 61 00:04:36.620 --> 00:04:40.830 was using a text based browser and even npw there is still some text base browsers 62 00:04:40.830 --> 00:04:46.690 on linux platforms primarily linux such as links in which is use fairly heavily 63 00:04:46.690 --> 00:04:50.430 the other thing to note is that some browsers for people with vision impairment 64 00:04:50.430 --> 00:04:55.740 count as text mode browsers so when it says the calling process will block the 65 00:04:55.740 --> 00:04:59.500 documentation means that the program will not continue until the text mode 66 00:04:59.500 --> 00:05:01.210 browser has been closed 67 00:05:01.210 --> 00:05:06.460 obviously in the case of this application when we ran it , it open the browser for 68 00:05:06.460 --> 00:05:10.840 us automatically but it didn't stop the program so the program continued on and created 69 00:05:10.840 --> 00:05:17.600 that helped to the right hand side of code, created this automatically in another words 70 00:05:17.600 --> 00:05:21.330 executed the next line so it didn't block in other ways in other words so 71 00:05:21.330 --> 00:05:25.760 this documentation in the screen here is basically to textual representation of 72 00:05:25.760 --> 00:05:30.039 that graphical documentation from that's in the chrome browser and you can 73 00:05:30.039 --> 00:05:34.050 see it automatically because I'm running a Mac it loaded that that was my default 74 00:05:34.050 --> 00:05:39.970 browser chrome and that's why use that to open the url that we gave on line 3 75 00:05:39.970 --> 00:05:44.280 so if a graphical browser is available or the program's not running under UNIX the program will continue 76 00:05:44.280 --> 00:05:48.340 once the browser has been launched and we saw that work there if the program had been block though 77 00:05:48.340 --> 00:05:51.979 we wouldn't see the results of calling help until we close the browser and 78 00:05:51.979 --> 00:05:56.280 clearly the browsers still running when we got it to work so it's quite important to 79 00:05:56.280 --> 00:06:00.110 understand that and that's the sort of thing that's generally mentioned 80 00:06:00.110 --> 00:06:02.720 documentation to give you some gotchas to know that under certain circumstances 81 00:06:02.720 --> 00:06:07.620 specific things may happen and we are gonna cover this when we look at creating our 82 00:06:07.620 --> 00:06:12.770 own modules but it is possible to create a .py file that can be executed as a 83 00:06:12.770 --> 00:06:17.270 script and also imported into other modules now web browser itself that modules 84 00:06:17.270 --> 00:06:21.180 is being written in this way so that the documentation mentions how it can be 85 00:06:21.180 --> 00:06:27.660 executed as a script from the command line 86 00:06:27.660 --> 00:06:31.680 you can see there its talking about how it can be invoked from a command line 87 00:06:31.680 --> 00:06:35.460 and you notice that the line has got a couple of extra parameters as well and you 88 00:06:35.460 --> 00:06:39.540 notice there is a couple of options on their -m as a parameter if your calling from the command 89 00:06:39.540 --> 00:06:44.080 line opens the URL in the browser window if possible and -t 90 00:06:44.080 --> 00:06:47.810 opens the url in a new browser page which is a tab and obviously can only do one or the 91 00:06:47.810 --> 00:06:51.020 other you can't do both because it is only gonna be only the being new browser window or 92 00:06:51.020 --> 00:06:56.080 a tab the point of all this is that the documentation is where you go to find this 93 00:06:56.080 --> 00:07:00.960 types of information when you're dealing with Python modules now there is also 94 00:07:00.960 --> 00:07:05.710 talk there about exceptions as you can see and we haven't looked at 95 00:07:05.710 --> 00:07:09.080 exceptions yet but they're a really useful way to handle errors in programs 96 00:07:09.080 --> 00:07:13.270 the note about the exception what they talk about their with the error that will 97 00:07:13.270 --> 00:07:17.300 make more sense later in the course once we have been through exceptions so the rest of the 98 00:07:17.300 --> 00:07:21.030 documentation as we scroll down is describing the various functions available in 99 00:07:21.030 --> 00:07:24.430 details of how to use them the open function for example you could see there 100 00:07:24.430 --> 00:07:28.670 we got that at the top of the screen there is called to provide it with the url which will 101 00:07:28.670 --> 00:07:32.890 then attempt to open a window in which we saw and there is also other versions 102 00:07:32.890 --> 00:07:37.190 of that as well there is other parameters we can call when we're creating that so again you 103 00:07:37.190 --> 00:07:41.160 can see how it's very useful to go through a module and find the 104 00:07:41.160 --> 00:07:45.010 documentation for it particularly with a standard library module that's part of 105 00:07:45.010 --> 00:07:48.860 Python to understand the various parameters and how to use them and to 106 00:07:48.860 --> 00:07:52.690 see what's available sometimes just going through the list the documentation 107 00:07:52.690 --> 00:07:56.870 should say for specific a module is really handy to see different parameters and 108 00:07:56.870 --> 00:08:01.340 again we used the .open but there's also there's this other options here .... 109 00:08:01.340 --> 00:08:05.620 .....and describing what they're actually used for as well so we've been using 110 00:08:05.620 --> 00:08:09.820 functions a lot of course the most common is using print which we have seen 111 00:08:09.820 --> 00:08:13.560 numerous times which just displays the arguments provided on the screen so this is a 112 00:08:13.560 --> 00:08:16.880 probably a good time now to have a quick look on arguments parameters in Python's 113 00:08:16.880 --> 00:08:21.220 named parameters so what we would do is to stick to the print function to define those terms 114 00:08:21.220 --> 00:08:25.930 back to the code editor and I know you have seen something similar to this and I'll just 115 00:08:25.930 --> 00:08:32.560 closed down this run window as well and we will close this down and comment those out for now we won't use those 116 00:08:32.560 --> 00:08:38.070 will comment out the help line as well so you've seen this before... 117 00:08:38.070 --> 00:08:54.100 and we run that....unsurprisingly the numbers from 0 through 9 but notice as I stop typing 118 00:08:54.100 --> 00:09:02.840 when I was typing now notice there its got objects but its got these other things on the end of the list as well so 119 00:09:02.840 --> 00:09:06.690 the Asterix before objects that means that we can provide several objects 120 00:09:06.690 --> 00:09:10.560 separated by commas and we've used this couple of times in the course so it shows 121 00:09:10.560 --> 00:09:13.520 that we can do things like the following we could do something like 122 00:09:13.520 --> 00:09:23.530 print.....and noting that they are all parameters as you can see so we provided nine arguments 123 00:09:23.530 --> 00:09:28.720 and print displays them on a single line so I won't run that but we know that it does that the values printed are 124 00:09:28.720 --> 00:09:32.850 separated by the character that is provided for the key word argument which is the 125 00:09:32.850 --> 00:09:38.600 sep which is the second parameters which you can see there so the default for value for sept is a 126 00:09:38.600 --> 00:09:43.100 space so we didn't specified value and numbers were separated by spaces so let just 127 00:09:43.100 --> 00:09:49.650 run that actually so that we can see what we are talking about and that was executed multiple times because I 128 00:09:49.650 --> 00:09:54.280 got a for loop but you can see that there's a space between each number and that's the 129 00:09:54.280 --> 00:09:59.790 of course the default for that parameter is a space so if you want to change that what will do is we close 130 00:09:59.790 --> 00:10:06.360 that down and at the end of the list where we don't want to put anymore parameters we put another comma but we type.... 131 00:10:06.360 --> 00:10:13.870 ...for separator remember that we brought up the list before.... 132 00:10:13.870 --> 00:10:21.300 ....and if we run that you can see we got a semi colon and a space between each number 133 00:10:21.300 --> 00:10:26.110 because we've set the separator is a semicolon and a space and likewise we 134 00:10:26.110 --> 00:10:32.870 could have got rid of the space, run that and now literally the numbers are separated only by a 135 00:10:32.870 --> 00:10:37.990 semicolon now print text three more arguments and we have a look at those again we 136 00:10:37.990 --> 00:10:41.810 can type print... 137 00:10:41.810 --> 00:10:45.590 what we could do here is you can see the other three parameters file and flush we've 138 00:10:45.590 --> 00:10:50.899 talked about those in section ten when we were dealing with input output but there is also other 139 00:10:50.899 --> 00:10:55.860 option for end and that's why by default you can see its going to go to a new line /n which 140 00:10:55.860 --> 00:11:01.850 means by default after we have process the line of output not individual pieces of 141 00:11:01.850 --> 00:11:05.309 information within a print but when it's finished the entire print statement as to 142 00:11:05.309 --> 00:11:18.209 whether or goes to new line or not we change that to put for example....and get rid of the second print and run that and you can see now 143 00:11:18.209 --> 00:11:20.929 that we're not going to a new line at the end of every print is staying just 144 00:11:20.929 --> 00:11:25.399 separating it by space so this is just an example of the print method and the various 145 00:11:25.399 --> 00:11:30.220 arguments that will actually take so let us just go back to the web browser documentation 146 00:11:30.220 --> 00:11:35.579 documentation for the functions provided by the web browser module it really is just showing 147 00:11:35.579 --> 00:11:40.149 the arguments the functions will accept and then describing what they do so the 148 00:11:40.149 --> 00:11:46.350 open function requires a url which you could see here and it can also accept two named arguments 149 00:11:46.350 --> 00:11:51.059 new and auto raise which will default to 0 when true if not specified 150 00:11:51.059 --> 00:11:56.279 back in the code you saw the end had default value of /n in which mean the print 151 00:11:56.279 --> 00:12:00.279 will automatically go to a new line at the of the print statement by default which if course you can override 152 00:12:00.279 --> 00:12:04.279 so lets try out some of these examples here of using the open functions so if we go 153 00:12:04.279 --> 00:12:13.980 back to our code I'm gonna comment out that for code and actually what I'll do is just delete it to make it easier and now if we go back and 154 00:12:13.980 --> 00:12:19.160 uncomment the web browser open by default we can you can see that would 155 00:12:19.160 --> 00:12:26.050 actually set that up to go to the url but we can put an unnamed parameter... 156 00:12:26.050 --> 00:12:30.649 and run that 157 00:12:30.649 --> 00:12:35.959 now the thing interesting here is don't be surprised if as in this case even though 158 00:12:35.959 --> 00:12:39.660 we used new equals 1 and we have a look at the documentation again 159 00:12:39.660 --> 00:12:44.999 new=1 a new browser window is open if possible and new=2 a browser page 160 00:12:44.999 --> 00:12:50.040 tab is opened and in theory you think that new=1 should open new instance of a browser so 161 00:12:50.040 --> 00:12:53.809 something like this new window that would be completely new window but it didn't actually 162 00:12:53.809 --> 00:12:58.110 do that so the key words to remember in this documentation is here if possible 163 00:12:58.110 --> 00:13:02.199 in this case it didn't do it opened it didn't in a new tab and this does apply to Google 164 00:13:02.199 --> 00:13:07.399 chrome and also to Fire Fox on Ubuntu Linux for example if you do that all three values 165 00:13:07.399 --> 00:13:12.040 result in your url being opened in a new tab of the current browser instance as you saw in mac 166 00:13:12.040 --> 00:13:15.740 when I did that as well again the documentation isn't incorrect it does state that 167 00:13:15.740 --> 00:13:19.319 the behaviors when apply when possible but moving on let us look at the open_new 168 00:13:19.319 --> 00:13:22.910 this provides the same functionality specify new=1 169 00:13:22.910 --> 00:13:28.230 and open_new_tab the next one down provides the same providing the 170 00:13:28.230 --> 00:13:32.689 parameter the parameter new=2 and actual fact each of these functions just 171 00:13:32.689 --> 00:13:37.949 call open with the new set value or new set sorry with new the named 172 00:13:37.949 --> 00:13:42.079 parameters set to the corresponding value so far the web browser module has been quite 173 00:13:42.079 --> 00:13:45.709 simple you can open a URL in one of three ways either by passing a value from 174 00:13:45.709 --> 00:13:50.009 the new parameter or calling one of the three open functions so the urls is going to be 175 00:13:50.009 --> 00:13:53.079 opened using your operating system's default browser and you can see in my case 176 00:13:53.079 --> 00:13:57.290 it was chrome let's look at another function this is the get function this 177 00:13:57.290 --> 00:14:02.689 is described as returning controller object for the specified browser type so 178 00:14:02.689 --> 00:14:09.990 hopefully you can see the table or the defined browser types and further down the 179 00:14:09.990 --> 00:14:14.290 document we can see the available methods in a controller on a controller is provided the three 180 00:14:14.290 --> 00:14:22.649 different ways of opening the URL that would actually just seen using the controller as you can see their so its 181 00:14:22.649 --> 00:14:26.319 a slightly different way of accessing in other words I just want to point out 182 00:14:26.319 --> 00:14:31.339 also that we've deliberately avoided the register function this is a good tip when 183 00:14:31.339 --> 00:14:35.160 reading module documentation focus on the functions that appear to do what you 184 00:14:35.160 --> 00:14:35.970 want 185 00:14:35.970 --> 00:14:39.519 only try to make sense of the other ones if you can't find any obvious way to do 186 00:14:39.519 --> 00:14:40.240 something 187 00:14:40.240 --> 00:14:44.700 so the get function provides everything we need to use a different browser to the system 188 00:14:44.700 --> 00:14:50.300 default so the following code if we go back to the browser I should actually opened the url in another 189 00:14:50.300 --> 00:15:00.190 browser so if we go back to the code close this down so comment that code out and if we change the code 190 00:15:00.190 --> 00:15:05.060 and you wanted to open in Google chrome and I've use that as a default but on your computer you should be able 191 00:15:05.060 --> 00:15:07.670 to type.... 192 00:15:07.670 --> 00:15:19.600 ..... 193 00:15:19.600 --> 00:15:25.910 ...... 194 00:15:25.910 --> 00:15:32.720 ....so if I run that I should probably get the same result because I'm actually running chrome 195 00:15:32.720 --> 00:15:36.250 anyway that would be the code that actually works but because I'm using a 196 00:15:36.250 --> 00:15:42.520 Mac I need to try one from another table so go back to the documentation 197 00:15:42.520 --> 00:15:56.020 you can see Mac with the mac options I can choose Safari by typing Safari or whatever the Mac OS X default is and just 198 00:15:56.020 --> 00:16:01.100 looking at this notes here obviously the Mac OS X ones are only applicable for 199 00:16:01.100 --> 00:16:05.700 the Mac platform and likewise with 2 Windows default is obviously only applicable to 200 00:16:05.700 --> 00:16:06.800 Windows platform 201 00:16:06.800 --> 00:16:13.079 so Chrome didn't work so let's just try running chrome in our test code 202 00:16:13.079 --> 00:16:23.040 so Google Chrome and run that you can see that didn't work either so what we can also try and do again this is probably MAC 203 00:16:23.040 --> 00:16:27.140 specific you should find these commands I've done here should work ok on 204 00:16:27.140 --> 00:16:31.250 a Windows machine or Linux machine but on a Mac you might have to do it slightly 205 00:16:31.250 --> 00:16:35.820 different so we can put Chrome... instead of putting 206 00:16:35.820 --> 00:16:40.470 using we get rid of using and will just make it..... 207 00:16:40.470 --> 00:17:02.080 ...lets try running again and see if that works that didn't work so I'll try actually what I did there I made a mistake 208 00:17:02.080 --> 00:17:09.980 so I need to put like so need to close of the bracket and put .open and you can see .open is now a method within that 209 00:17:09.980 --> 00:17:19.230 function so we close it down and run it again no error this time but we didn't see it actually open anything 210 00:17:19.230 --> 00:17:24.000 so we're on the right track here so let us try closing that down and putting Google 211 00:17:24.000 --> 00:17:36.470 Chrome run that will try .open_new_tab.....like so 212 00:17:36.470 --> 00:17:52.540 run that close that down and we will just make that chrome again I'll just try one more and again this is a Mac specific problem.... 213 00:17:52.540 --> 00:18:00.360 will try and execute that and again no luck so not having much luck with the Mac version but if we just got back 214 00:18:00.360 --> 00:18:03.870 to the documentation again what we can do we know that we can get it to work 215 00:18:03.870 --> 00:18:06.900 using Safari so that's something that does work on a Mac and again these 216 00:18:06.900 --> 00:18:10.850 problems are pretty much because I'm actually running this on a Mac and you 217 00:18:10.850 --> 00:18:14.740 can see on Windows you should be able to use Chrome or Google_chrome that 218 00:18:14.740 --> 00:18:18.190 should work just fine but it is not working on my Mac at the moment so I'm gonna use 219 00:18:18.190 --> 00:18:22.760 Safari which we know I haven't executed before lets go back and change 220 00:18:22.760 --> 00:18:27.260 the code for that so I'm gonna make it a lot simpler so I'm gonna go back to the code 221 00:18:27.260 --> 00:18:36.300 I have and I'm going to comment out that line for now I'm gonna put.... 222 00:18:36.300 --> 00:18:45.790 ...and will put....which should now work because we are on a Mac and that will only work on a Mac 223 00:18:45.790 --> 00:18:49.430 Chrome sorry Safari.... 224 00:18:49.430 --> 00:19:08.140 ...lets try that so that worked of screen so I'm going to close the tab down and 225 00:19:08.140 --> 00:19:13.920 opened it moved Safari over to this screen and I'm just gonna make it big so we got 226 00:19:13.920 --> 00:19:18.780 2 tabs opened as you can see and if I run this again you can see that came up and work this 227 00:19:18.780 --> 00:19:22.980 time so that's using Safari so basically the code I was trying to work was Mac 228 00:19:22.980 --> 00:19:27.470 specific and it didn't work because we're on a Mac but once I started putting Mac 229 00:19:27.470 --> 00:19:32.670 specific code it actually worked and again getting back to the other code if 230 00:19:32.670 --> 00:19:36.410 you're using these codes on a Windows machine not Mac OS X and safari but the 231 00:19:36.410 --> 00:19:39.580 other ones you should find that there's no problems basically problem initially 232 00:19:39.580 --> 00:19:44.220 with those errors was as far as Mac was concerned it couldn't find Google Chrome and it needs to 233 00:19:44.220 --> 00:19:48.520 be in the system path and it raise an error and you saw those exceptions coming up 234 00:19:48.520 --> 00:19:51.530 on the screen and you'll be learning how to deal with those exceptions later in the 235 00:19:51.530 --> 00:19:55.280 course and doing so will provide a way to check gracefully whether a 236 00:19:55.280 --> 00:19:59.110 particular browser is available so you can try another one if not so again you might want to 237 00:19:59.110 --> 00:20:03.760 as an exercise just try one of these options on your computer and see if it 238 00:20:03.760 --> 00:20:07.470 actually works and you can see I actually use safari in my case and just finishing off 239 00:20:07.470 --> 00:20:12.160 I know this is getting quite long but the register function that we skipped over getting back to the 240 00:20:12.160 --> 00:20:18.230 documentation register here that can be used to make additional browsers 241 00:20:18.230 --> 00:20:22.620 available when Python doesn't list them in the table so in actual fact it can be 242 00:20:22.620 --> 00:20:26.290 used to make unknown browsers available in the system path and that was 243 00:20:26.290 --> 00:20:32.490 obviously the case here with those errors I was getting however with this bit of the documentation is fairly weak it doesn't 244 00:20:32.490 --> 00:20:38.540 specifically say what the constructor argument is although we could guess what it does some sort of function there is no 245 00:20:38.540 --> 00:20:43.140 indication of what it should do the final paragraph of register does say that the function is 246 00:20:43.140 --> 00:20:47.860 only useful if you plan to either set the browse variable or declaring your own handler 247 00:20:47.860 --> 00:20:53.370 but again what is handler does and what form it should take is unspecified so if you do get to the point where you feel you need 248 00:20:53.370 --> 00:20:57.860 to use a function or method that's poorly documented your only real choices 249 00:20:57.860 --> 00:21:01.290 are to searched the internet or examine the module source code we don't actually 250 00:21:01.290 --> 00:21:02.480 use this function right 251 00:21:02.480 --> 00:21:04.910 now which is fortunate because an internet search in this particular 252 00:21:04.910 --> 00:21:08.900 function throws up far less information than is normally available when it's a 253 00:21:08.900 --> 00:21:13.520 bit too soon and of course for examining the web browser source code so hopefully this tour 254 00:21:13.520 --> 00:21:18.400 of the library documentations has given you like a solid idea of how to use it 255 00:21:18.400 --> 00:21:22.770 and how to work out what various functions do and how they used occasionally you'll 256 00:21:22.770 --> 00:21:26.280 find the odd bit of documentation that's not as good as it should be as in the register 257 00:21:26.280 --> 00:21:30.630 example here on the screen but generally speaking the Python documentation is 258 00:21:30.630 --> 00:21:34.850 quite good so we are gonna finish this lecture now with 2 last comments that be useful when 259 00:21:34.850 --> 00:21:38.580 looking at documentation and method descriptions the first is the difference 260 00:21:38.580 --> 00:21:42.690 between arguments and parameters and why it doesn't matter so strictly 261 00:21:42.690 --> 00:21:46.160 speaking when you write your own function what you doing is your defining 262 00:21:46.160 --> 00:21:49.690 the parameters that its going to use and when the function is called these 263 00:21:49.690 --> 00:21:53.940 parameters are replaced with the actual arguments in practice most programmers 264 00:21:53.940 --> 00:21:57.740 now used to the two words interchangeably and generally favor the word parameter 265 00:21:57.740 --> 00:22:02.770 over arguments and the Python documentation does have a glossary entry explaining 266 00:22:02.770 --> 00:22:05.860 the difference but in the description of the register function that we just 267 00:22:05.860 --> 00:22:09.500 looked at it states that the constructor can be called without parameters when it 268 00:22:09.500 --> 00:22:14.000 actually means without arguments which justifies our advise not to worry too much 269 00:22:14.000 --> 00:22:18.040 about the terms and a second thing I want to point out is the parameter called 270 00:22:18.040 --> 00:22:19.260 self 271 00:22:19.260 --> 00:22:23.450 we are going to be covering classes in the next section actually and you'll learn about the 272 00:22:23.450 --> 00:22:26.580 difference between functions and methods but until then when you call a method in 273 00:22:26.580 --> 00:22:30.400 the same way you do a function as we did with shelve.open for example in the 274 00:22:30.400 --> 00:22:34.100 previous section but in the documentation for method you see that the first 275 00:22:34.100 --> 00:22:39.150 parameter or argument to a method is self but you don't have to provide a value 276 00:22:39.150 --> 00:22:42.340 for it when you calling the method Python takes care of this for you so just 277 00:22:42.340 --> 00:22:46.960 ignore self for now and again this will all be revealed in covered in detail when we 278 00:22:46.960 --> 00:22:51.360 cover object orientated programming classes later in the course so that's it 279 00:22:51.360 --> 00:22:54.190 I'm gonna finish is very long video now and I'll see you in the next video