![]() So in this case, mod2 is going to be all the way at the top level of the symbol table, so mod2.clean_data() is available.Ġ2:17 Or again, you can import individual items. You could say from sub_pkg1 import mod2, so mod2 is there.Ġ2:02 It’s just going to change the level of dot notation. This is it just using the different forms, right, so you can import mod1. You could import sub_pkg1.mod2-Ġ1:53 or actually import all of it. It’s just extending the module in the dot notation.Ġ1:43 You can also use the from syntax. Customer and load_data() are both available there. So pkg.sub_pkg1.mod1-well, that would importĠ1:36 all of mod1. To import things, you just continue to use dot notation, except for now you have an additional level. Back here in the terminal, go ahead and start your REPL. Okay.Ġ1:02 And as a reminder, mod1 has load_data() and Customer, mod2 has clean_data() and Location, mod3 has merge_data() and Message, and mod4 has send_mail() and Winner.Ġ1:15 Okay. pkg/ has sub_pkg1/ and sub_pkg2/, which has mod1 and mod2 and mod3 and mod4 inside of them. For this example, you’re not going to use the _init_.py, so go ahead and delete that file.Ġ0:36 And inside the pkg/ directory, create a new directory sub_pkg1, and then move mod1 and mod2 inside of it.Ġ0:46 And then create another directory sub_pkg2, and inside sub_pkg2/ move mod3 and mod4. Underneath that, create a subdirectory called sub_pkg1 and sub_pkg2.Ġ0:20 And then inside sub_pkg1/, you’ll have mod1 and mod2 and in sub_pkg2- mod3 and mod4.Ġ0:25 You’ll use the similar dot notation to access all of these. ![]() For this example, you’ll start with package pkg. Packages can be nested to contain subpackages, and that can be done to an arbitrary depth. ![]() 00:00 In this video, you’ll explore subpackages.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |