0

so the below code is supposed to take the first element in the resulting tuple of x and convert it to a string to be used. However, when executing the last line it tells me it can't convert from tuple to str.

for x in filelink:
            print(x[0])
            item = str(x[0])
            oldpath = root.wgetdir + "\\" + root.website.get() + "\\" + item
            print(oldpath)
            if os.path.exists(oldpath): shutil.copy(root.wgetdir + "\\" + root.website.get() + "\\" + x, keyworddir + "\\" + item)
5
  • x, keyworddir creates a tuple and you are trying to concatenate that with a string. Commented May 8, 2014 at 5:06
  • @thefourtheye: No, that's the comma between function arguments. Commented May 8, 2014 at 5:06
  • Can't really tell because you haven't posted what filelink is or the exact exception you are receiving, but it sounds like x[0] is itself a tuple. Commented May 8, 2014 at 5:06
  • @user2357112 Oh, You are correct :) +1 Commented May 8, 2014 at 5:06
  • 1
    @Kyle: Don't concatenate file paths manually. Use os.path.join. Commented May 8, 2014 at 6:21

1 Answer 1

2

This part:

root.wgetdir + "\\" + root.website.get() + "\\" + x
                                       right here ^

is using the tuple instead of item.

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.