Prometheus
Prometheus

Reputation: 33615

Python error not enough arguments for format string

Can anyone tell me whats wrong with this:

put(('%s%s.tar.gz' % config.SERVER_PROJECT_PATH, config.RELEASE))

TypeError: not enough arguments for format string

I just want insert two variables in to the string, is my syntax correct?

Upvotes: 1

Views: 2801

Answers (2)

Robin Krahl
Robin Krahl

Reputation: 5308

The syntax is incorrect. The string formatting arguments must be a tuple. You are creating a tuple with the formatted string and the second formatting argument. Use this instead:

put("%s%s.tar.gz" % (config.SERVER_PROJECT_PATH, config.RELEASE))

Upvotes: 2

Martijn Pieters
Martijn Pieters

Reputation: 1121614

You need to put the two values in a tuple:

put('%s%s.tar.gz' % (config.SERVER_PROJECT_PATH, config.RELEASE))

otherwise Python sees this as two separate expressions to form a tuple, '%s%s.tar.gz' % config.SERVER_PROJECT_PATH and config.RELEASE.

Upvotes: 5

Related Questions