os.path.exists discrepancy

R

Robert Brewer

I've got a webapp which is behaving oddly. I want to include an image on
the webpage, but only if the physical file exists; if it doesn't, I
don't want an img element to generate an ugly blank box. I know the
physical location of the image(s) in question, and figured I'd use
os.path.exists to see if each file exists. A quick test in the
interpreter yields:
True

However, when I run the following code in the webapp (served by Apache2
+ mod_python on the same Win2k machine):

if not os.path.exists(path):
scan = u"<!-- scan image not found: %s -->" % repr(path)

....I get the output:

<!-- scan image not found: u'S:/Scans/Projects/2004/TJ/04TJ0267.jpg' -->

As you can see, the two paths are equal. Prompting my reaction: bzuh? My
next thought was to read through the os module source--perhaps the
import of "path" was dependent on context. It is, but os.path.__file__
is the same in both contexts: 'C:\\Python23\\lib\\ntpath.pyc'

Any ideas or workarounds?


Robert Brewer
MIS
Amor Ministries
(e-mail address removed)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

distutils and decorators 0
fixedpoint cmp conundrum 1
xray module 0
pygarmin eTrex Legend comm problems 0

Members online

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,902
Latest member
Elena68X5

Latest Threads

Top