antontama antontama - 1 year ago 301
Python Question

os.path.join() takes exactly one argument (2 given)

i'm getting python error:
TypeError: join() takes exactly one argument (2 given) in line 139, of set_Xpress method, which looks like this:

from os import path
from json import load
def set_Xpress(Xpress_number, special_ts, disk, platform, testcase):
with open("{0}:\\BBT2\\Configuration\\temporary.tmp".format(disk), "r") as test_conf_file_r:
test_conf_vocab = load(test_conf_file_r)
report = path.join(test_conf_vocab["report_dir"], test_conf_vocab["report_name"])

Please, help me understand what cause it. Python shell executes it with no problems, and the same stroke executed fine in another method with this tmp file. Thanks in advance.

Answer Source

path is not the os.path module, it's a string. You redefined it somewhere.

from os import path  # path is a module, path.join takes many arguments


path = '/some/path'  # path is now a string, path.join is a totally
                     # different method, takes a single iterable

report = path.join(one, two)   # TypeError, str.join takes one argument
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download