-3

I am new to Python and I am trying to run the following lines in Python 3.4. The file is downloaded from Yelp.com and is ready-to-use:

url_params = url_params or {}
url = 'http://{0}{1}?'.format(host, path)

consumer = oauth2.Consumer(CONSUMER_KEY, CONSUMER_SECRET)
oauth_request = oauth2.Request(method="GET", url=url, parameters=url_params)

oauth_request.update(
    {
        'oauth_nonce': oauth2.generate_nonce(),
        'oauth_timestamp': oauth2.generate_timestamp(),
        'oauth_token': TOKEN,
        'oauth_consumer_key': CONSUMER_KEY
    }
)
token = oauth2.Token(TOKEN, TOKEN_SECRET)
oauth_request.sign_request(oauth2.SignatureMethod_HMAC_SHA1(), consumer, token)
signed_url = oauth_request.to_url()

print 'Querying {0} ...'.format(url)

In the last line:

print 'Querying {0} ...'.format(url) I get an error message: SyntaxError: invalid syntax
styvane
  • 59,869
  • 19
  • 150
  • 156
Asteroid
  • 1,049
  • 2
  • 8
  • 16

2 Answers2

0

In Python 3 and up the argument to print has to be inside parenthesis:

print('Querying {0} ...'.format(url))

Márcio Paiva
  • 983
  • 9
  • 25
0

In Python 3x you have to put paranthesis in print function.

print ('Querying {0} ...'.format(url))

For example you can't do this;

print "hello"

You have to write that like;

print ("hello")
GLHF
  • 3,835
  • 10
  • 38
  • 83