1 00:00:00,000 --> 00:00:02,910 Once you start working with Python more and more chances 2 00:00:02,910 --> 00:00:06,330 are you are going to outgrow using Jupyter Notebook, and you're 3 00:00:06,340 --> 00:00:08,990 going to start using your command line a lot more. 4 00:00:09,000 --> 00:00:13,860 Now, with that comes a Python shell, and you can write all 5 00:00:13,860 --> 00:00:15,900 sorts of Python stuff in here if you wanted to. 6 00:00:15,900 --> 00:00:18,400 We can say 'print(Hi")'. 7 00:00:18,460 --> 00:00:23,980 'def func_name()' doesn't really do auto indenting, 8 00:00:23,990 --> 00:00:26,170 so we've got to indent that for us for ourselves. 9 00:00:26,410 --> 00:00:27,370 'print("Hello")', 10 00:00:28,000 --> 00:00:31,300 and then we could run 'func_name'. 11 00:00:31,360 --> 00:00:32,470 Now, that's not bad. 12 00:00:32,479 --> 00:00:35,710 This is kind of boring to look at, but we can experiment 13 00:00:35,720 --> 00:00:38,860 with some Python in there, or if you want something that's 14 00:00:38,870 --> 00:00:41,860 a little more like Jupyter Notebook, but on your command 15 00:00:41,870 --> 00:00:45,820 line, you can install this thing called 'ipython', and you 16 00:00:45,830 --> 00:00:47,320 can do that with 'pip install 17 00:00:47,320 --> 00:00:51,700 ipython', which I think actually I already have. 'pip freeze ipython'. 18 00:00:51,700 --> 00:00:53,500 I should have it. I use it a lot. 19 00:00:53,510 --> 00:00:55,230 Not 'pip freeze', 20 00:00:55,230 --> 00:00:56,500 I meant 'pip show'. 21 00:00:56,960 --> 00:01:02,310 And yup, I am using IPython7.11.1. 22 00:01:02,540 --> 00:01:05,209 So you can do 'pip install ipython'. 23 00:01:05,220 --> 00:01:07,910 That will get you the latest version of Python or IPython, 24 00:01:07,910 --> 00:01:11,650 rather. An IPython is just interactive Python, and you can 25 00:01:11,660 --> 00:01:14,940 type 'ipython' instead of typing 'python', 26 00:01:14,950 --> 00:01:17,310 and this will give you an interactive shell. 27 00:01:17,540 --> 00:01:20,030 Now you can already see this looks a little bit different. 28 00:01:20,040 --> 00:01:24,020 And let's just make some room here, and let's do the exact 29 00:01:24,030 --> 00:01:25,850 same examples we did in the regular shell. 30 00:01:25,850 --> 00:01:27,600 'print("Hello")'. 31 00:01:27,600 --> 00:01:29,500 So we already have syntax highlighting. 32 00:01:29,500 --> 00:01:30,900 That's nice. That's really nice. 33 00:01:30,900 --> 00:01:33,700 'def func_name()'. 34 00:01:33,720 --> 00:01:36,280 It does auto indentation for us. 35 00:01:36,280 --> 00:01:38,300 That's nice. "Hello World". 36 00:01:38,360 --> 00:01:40,730 We can execute 'func_name' in here. 37 00:01:40,740 --> 00:01:42,050 "Hello world", 38 00:01:42,170 --> 00:01:43,700 and it's just a little nicer. 39 00:01:43,730 --> 00:01:46,700 Now, if you're using interactive Python with a framework 40 00:01:46,710 --> 00:01:50,510 such as Django, it will also do a bunch of automatic imports 41 00:01:50,520 --> 00:01:52,220 for you, which is really, really nice. 42 00:01:52,440 --> 00:01:55,500 Now, while this does do pretty much everything the regular 43 00:01:55,510 --> 00:01:57,780 Python shell does, this is just a little nicer to look at. 44 00:01:57,800 --> 00:02:01,040 And as a little more advanced example of something you can 45 00:02:01,050 --> 00:02:03,800 do in the Python shell, or in the interactive shell that we're using 46 00:02:03,810 --> 00:02:07,620 here, we can import a file or a function from a file. 47 00:02:07,630 --> 00:02:09,240 So let's go ahead and take a look here 48 00:02:09,240 --> 00:02:10,600 what do we have to import. 49 00:02:10,660 --> 00:02:14,740 So I just called 'ipython' from my directory where I have 50 00:02:14,750 --> 00:02:15,700 all of these files here, 51 00:02:15,820 --> 00:02:17,200 and 'custom_module'. 52 00:02:17,200 --> 00:02:18,900 Yeah, so let's do 'from 53 00:02:18,900 --> 00:02:21,200 [no audio] 54 00:02:21,200 --> 00:02:23,300 custom_module', I could do tab completion, 55 00:02:23,300 --> 00:02:25,000 that's nice, 'import', 56 00:02:25,060 --> 00:02:29,380 and if I do tab completion, I can import all sorts of stuff, 57 00:02:29,390 --> 00:02:32,230 but I really only have the one function here called 'my_greeting', 58 00:02:32,240 --> 00:02:34,580 and I can do 'my_greeting()' as a function. 59 00:02:36,200 --> 00:02:40,700 And now I've imported a file. From my computer 60 00:02:41,220 --> 00:02:43,800 I've imported a function, and I've run that function. 61 00:02:43,810 --> 00:02:47,920 And so with interactive Python, you can do all that stuff. 62 00:02:47,930 --> 00:02:50,200 Again, you can do a lot of the stuff with the regular Python 63 00:02:50,210 --> 00:02:52,390 shell, but this one just looks a lot nicer. 64 00:02:52,700 --> 00:02:55,670 This also has a bunch of nice little shortcuts that you can 65 00:02:55,680 --> 00:02:56,870 get into if you want to. 66 00:02:56,880 --> 00:02:58,370 I don't really use too many of them. 67 00:02:58,540 --> 00:03:01,420 I just think this is a nicer version of a Python shell. 68 00:03:01,540 --> 00:03:04,900 So if you like nice things, and you like to have a nice shell, 69 00:03:05,080 --> 00:03:10,030 go ahead, and let's quit this, 'pip install ipython', 70 00:03:10,040 --> 00:03:12,640 and then once you've got that, just run 'ipython'. 71 00:03:12,640 --> 00:03:13,600 [no audio]