Drop Down List

I would think so too...

Ok, that was interesting. I did a lot of digging, and it looks like Jython file management is a little different from Python. I dug up a note where I might actually have to use Java instead to remove a file in Jython.

But enough of that for now. What I did was rewrite my code to use file objects instead, so there are no longer any physical temp files created. I only did it that way originally so I would have something to troubleshoot with anyway, so it’s no loss.

But, I was wondering if I can do anything to make the code run faster. I don’t know what fpmi is actually doing in the background while the script is executing (is my script being constantly interupted or something?). This is what I am seeing:

  1. If I run rip.exe from Explorer, it takes about a second to rip through two zips and create the new files.

  2. If I call rip.exe from fpmi, it takes about 2s.

  3. If I run the script from Wing IDE debugger (my dev environment), it takes 6s.

  4. If I run the script from fpmi, it takes 20s.

Obviously, I’d like to speed this up a bit. I was digging through the docs, and wondering if something like invokeAsychronous would help, or some other trick. I haven’t spent a ton of time optimizing my code yet, but I would like to understand why I’m getting such different execution times first.

I’m not sure - I’d have to compare the code to understand the speed difference. Jython is really really fast (it actualy compiles down to java bytecode, which is then hotspot-compiled to native code…), so I’d suspect something in the code. Maybe we can look at it together on Monday?

Monday would be fine. The code is identical in all four examples though, so I’m not sure that’s it. Let’s take a look.

[quote=“Carl.Gould”]And for your last question, os.walk is a 2.3 feature, but we can do our own walking with a recursive function. Here is a function that will find all text files below some directory:

[code]results = []

def match(self, startDir, results=results):
import os
for fileName in os.listdir(startDir):
f = startDir + ‘/’ + fileName
if os.path.isdir(f):
self(self, f)
elif fileName.find(’.txt’) != -1:
results.append(f)

match(match, ‘c:/mydir’)

for f in results:
print f[/code]
[/quote]

I’m getting deep into this now, and if anyone is planning on doing file management, this recursive search is pretty cool. But I wanted to mention one problem: When appending or inserting strings in a list, you have to wrap them with [] first. Otherwise, the characters in the string become a list in themselves. By changing the resuts.append(f) to results.append([f]), it worked perfectly.