os.listdir(path) seems to be working for me:

>>> if 'sets.py' in os.listdir('.'): print 'hello'
...
hello

(running in the Python lib dir)

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of JoeSox
Sent: Monday, June 26, 2006 5:38 PM
To: Discussion of IronPython
Subject: [IronPython] odd IronPython behavior?

In short, I am observing IronPython completely go thru the below method and 
only to return empty, while other Python environments return a value and exit 
on the first return statement.  I believe this may be some sort of bug. Can 
someone confirm this for me, otherwise I will need to troubleshoot this more. 
"filename" is assigned with one file name in both IronPython and Python.  I 
don't know if
os.listdir(path) is operational in IronPython or I am not loading paths in 
there or what.
I have some modified ConceptNet script files and I almost have it running in 
IronPython which is exciting but as you can see I am still working on some 
things.

Thanks, as always.

====method ...
    def find_file(self,filename):

        if filename in os.listdir('.'):
            return './'+filename

        if os.environ.has_key('MONTYLINGUA'):
            csplits=os.environ['MONTYLINGUA'].split(';')
            csplits=map(lambda groupss:groupss.strip(),csplits)
            for enabled_arr in csplits:
                try :
                    if filename in os.listdir(enabled_arr):
                        return enabled_arr+'/'+filename
                except :
                    pass
        if os.environ.has_key('PATH'):
            csplits=os.environ['PATH'].split(';')
            csplits=map(lambda groupss:groupss.strip(),csplits)
            for enabled_arr in csplits:
                try :
                    if filename in os.listdir(enabled_arr):
                        return enabled_arr+'/'+filename
                except :
                    pass
        return ''


--
Later, Joe
_______________________________________________
users mailing list
[email protected]
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
_______________________________________________
users mailing list
[email protected]
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com

Reply via email to