0

I used import twitter and then tried authenticating using the following command - Twitter(auth=OAuth(access_token, access_token_secret, consumer_key, secret_key))

On running the program I get the error: name Twitter not defined. When I use from twitter import *, it works. Why is it so?

I am asking this because if i use tweepy instead, a simple import tweepyworks. Also, doesn't import twitter work the same as from twitter import *?

1
  • 2
    Importing a module does not make all the components inside the module directly visible; you have to prepend the module name as in twitter.Twitter(...). As you noted, using from module import * does make the items inside the module directly visible. Commented Jul 21, 2020 at 16:43

1 Answer 1

2

Try twitter.Twitter (auth=OAuth(access_token, access_token_secret, consumer_key, secret_key))

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.