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

Reedick, Andrew jr9445 at ATT.COM
Thu May 15 12:11:27 EDT 2008


> -----Original Message-----
> From: python-list-bounces+jr9445=att.com at python.org [mailto:python-
> list-bounces+jr9445=att.com at python.org] On Behalf Of globalrev
> Sent: Thursday, May 15, 2008 12:04 PM
> To: python-list at python.org
> Subject: exists=false, but no complaint when i open it!?
> 
> print os.path.exists('C:\Users\saftarn\Desktop\NetFlixDataSet
> \trainingsetunzipped\training_set\mv_0000001.txt')
> 
> d=open('C:/Python25/myPrograms/mapexperiments/maps/provinces-of-
> sweden.gif')
> d.close()
> 
> exists returns false but when i open it doesnt complain. how come?
> 
> another file that exists returned false for complained when i tried to
> open it.
> --


You're falling victim to string interpolation because of the
backslashes.  (\n == newline, \N == N).

Try using a raw string r'filename', instead of 'filename':
	print
os.path.exists(r'C:\Users\saftarn\Desktop\NetFlixDataSet\trainingsetunzi
pped\training_set\mv_0000001.txt')


*****

The information transmitted is intended only for the person or entity to which it is addressed and may contain confidential, proprietary, and/or privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender and delete the material from all computers. GA621





More information about the Python-list mailing list