Doubled backslashes in Windows paths

BartC bc at freeuk.com
Fri Oct 7 12:50:05 EDT 2016


On 07/10/2016 13:39, BartC wrote:
> On 07/10/2016 06:30, Oz-in-DFW wrote:

>> I'm getting an error message on an os.path.getsize call;

> But the main error appears to be due to the presence of quotes, whether
> at each end, or inside the path, enclosing an element with spaces for
> example. Try using len(path)>10000 instead; it might be near enough (the
> 10000 sounds arbitrary anyway).

Forget that. Apparently .getsize returns the size of the file not the 
length of the path! (That os.path. bit misled me.)

In that case just leave out the quotes. I don't think you need them even 
if the file-path contains embedded spaces. That would be an issue on a 
command-line (as spaces separate parameters), not inside a string.

But if quotes are present in user-input that represents a file-name, 
then they might need to be removed.

-- 
Bartc



More information about the Python-list mailing list