1

I'm using Python 2.7 and developing an application in both Ubuntu and Windows. On Windows it works fine---no issues. But on Ubuntu it seems to be doing something odd on this bit:

numberoffiles = raw_input('\nHow many files would you like to compare? ')
numberoffiles = int(numberoffiles)

filelist = []
for i in range(numberoffiles):
    myfilename = raw_input('\nEnter a file path: ')
    filelist.append(myfilename)
print filelist

I'm expecting a list of file names in the format:

['path/to/file1.ext','path/to/file2.ext',...]

But Python is adding double quotes and spaces, so that I get:

["'/path/to/file1.ext' ", "'/path/to/file2.ext' ",...]

If it's a quirk, I can get around it, but I'd like to understand what I'm doing wrong or what exactly is happening here. Any answers would be appreciated.

1
  • What's the exact input you are giving it on each of the platforms? Commented Apr 19, 2013 at 5:23

2 Answers 2

1

You will need to check your input. If you are giving the input as '/path/filename' then even on windows you will have the double quotes added. Ensure you don't add quotes when you are providing the input.

Sign up to request clarification or add additional context in comments.

Comments

0

My money is on the extra quotes (and trailing spaces) being part of the input you are providing to the script.

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.