exists=false, but no complaint when i open it!?

Andreas Tawn andreas.tawn at ubisoft.com
Thu May 15 13:20:58 EDT 2008


>print os.path.exists('C:\Users\saftarn\Desktop\NetFlixDataSet
>\training_set') returns False...
>
>i have thourogly checked the filename to be correct and if we assume
>it is what could this mean then?
>i had a problem one other time when i had renamed a file but windows
>didnt rename it compeltely apparently.

It's escape characters again.

You're asking for
'C:\Users\saftarn\Desktop\NetFlixDataSet\training_set', but Python
interprets that as 'C:\Users\saftarn\Desktop\NetFlixDataSet
raining_set', which probably doesn't exist.

The first example works by accident because backslash plus the first
letter of each folder in your path happens to not match any of Python's
string formatting characters.

Use forward slashes or double up the backslashes to stop this happening.

Cheers,

Drea



More information about the Python-list mailing list