-2
  from twilio.rest import Client

account_sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
auth_token = "your_auth_token"
client = Client(account_sid, auth_token)

for sms in client.messages.list():
    print(sms.to)

here what is the meaning of keyword "from"?

  • 1
    Welcome to StackOverflow. Please read and follow the posting guidelines in the help documentation, as suggested when you created this account. [On topic](http://stackoverflow.com/help/on-topic), [how to ask](http://stackoverflow.com/help/how-to-ask), and [... the perfect question](https://codeblog.jonskeet.uk/2010/08/29/writing-the-perfect-question/) apply here. StackOverflow is not a design, coding, research, or tutorial resource. – Prune Nov 09 '18 at 23:50
  • 2
    Very simply, this is easy to look up -- and we expect you to do so before posting here. – Prune Nov 09 '18 at 23:51
  • 2
    Possible duplicate of [How to import other Python files?](https://stackoverflow.com/questions/2349991/how-to-import-other-python-files) – DarkSuniuM Nov 10 '18 at 00:41

2 Answers2

1

It allows you to import an element from a module without referencing the full module name to use it.

For example:

import time
time.sleep(10) # to sleep for 10 seconds

as opposed to

from time import sleep
sleep(10)
D M Lowe
  • 187
  • 1
  • 6
0

Allows you to import specific methods from a module without importing the entire library. If you want to import every method in that module, you can also use for example:

from pandas import *
mlenthusiast
  • 1,094
  • 1
  • 12
  • 34
  • This allows you to import specific *names*, not *methods*. While theoretically, a method could be bound to some module-level name, that is unlikely. You probably mean *function* – juanpa.arrivillaga Nov 10 '18 at 00:24