Question

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.

Was it helpful?

Solution

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

OTHER TIPS

os.path.join() takes any number of arguments. Are you sure your path.join is actually calling os.path.join?

Absolutely os.path.join() takes as many as argument,like the one who said you have definitely redefined the path as a new variable and stored as a string so,be careful about.Though i did absolutely this and after a long search and trial i found my error.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top