English subtitles

← Investigating the Code - Programming Foundations with Python

Get Embed Code
7 Languages

Showing Revision 4 created 05/24/2016 by Udacity Robot.

  1. So the best way to find out about anything is to Google it. So I typed in Python
  2. keyword from. Here I scanned all of the results
  3. that were available, and then from there I landed
  4. on this web page. By the way the link to this web site is also available in the
  5. instructor notes. Now this webpage says that Python's from
  6. statement lets you import specific attributes from a module. So
  7. I guess it allows you to say from module or filename import something. So I
  8. guess our code that means, that from
  9. something called twilio.rest, we want to import TwilioRestClient.
  10. Now, this got me curious about what
  11. these things called Twilio.rest and TwilioRestClient were. So
  12. then I went back to Google and tried
  13. to find out how Twilio was actually implemented,
  14. so I typed in Twilio Python Code. Then
  15. I looked through these results and I got to
  16. this website called GitHub. Here I could read
  17. all of the code that actually makes Twilio work
  18. behind the scenes, by the way, this link
  19. is also available in the instructor notes. Now in
  20. the code for twilio I find that there was
  21. a folder called twilio so I clicked on it,
  22. now inside that folder is another folder called rest. And within
  23. rest there is a py on file which, if we look through, we will find that there is
  24. a class called class TwilioRestClient inside it. So when we write this line
  25. of code from twilio.rest import TwilioRestClient
  26. what we are telling the computer is, hey, inside Twilio. There
  27. is a folder called rest and inside that folder
  28. is a class called twlio rest client and we are
  29. going to use that class inside our code. And
  30. if we go back and look in our code here
  31. is how we are using that class twilio rest
  32. client. Now you know if we were writing this code
  33. from scratch we probably wouldn't have written this line
  34. of code. We would have modified it to say from
  35. twilio import rest. Now with this line of code, what we are telling the computer
  36. is, hey inside the folder twilio is
  37. another folder called Rest. Import that because we
  38. are going to use that in our program, and we know that inside the folder
  39. rest is the class TwilioRestClient. So I would
  40. now access that class by saying rest. TwilioRestClient.
  41. Let me save, and run this program one more
  42. time to see if it still works. All right?
  43. Here's my phone and let's see if I get
  44. a text message any time soon. [SOUND] Ah-hah! There's
  45. the text message, it seems like our program still
  46. works. So in the next video what I want to
  47. do is revisit the idea of how twilio, rest,
  48. and twilio rest client are related with one another.