# Drop Down List

**URL:** <https://forum.inductiveautomation.com/t/drop-down-list/554>\
**Category:** Archived Topics\
**Created:** [February 15, 2008, 6:50pm UTC](https://forum.inductiveautomation.com/t/drop-down-list/554 "2008-02-15T18:50:12Z")\
**Posts on this page:** 5\
**Page:** 2

<div class="post-metadata">

**Author:** ![Carl.Gould](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/carl.gould/32/7262_2.png) [@Carl.Gould](https://forum.inductiveautomation.com/u/Carl.Gould)\
**Post date:** [May 30, 2008, 9:27pm UTC](https://forum.inductiveautomation.com/t/drop-down-list/554/21 "2008-05-30T21:27:51Z")

</div>

> [@Step7](#):
>
> ... I would think that if I explicitly open and close each one at the end, then I should be able to remove them.

I would think so too...

---

<div class="post-metadata">

**Author:** ![Step7](https://avatars.discourse-cdn.com/v4/letter/s/45deac/32.png) [@Step7](https://forum.inductiveautomation.com/u/Step7)\
**Post date:** [May 31, 2008, 5:45pm UTC](https://forum.inductiveautomation.com/t/drop-down-list/554/22 "2008-05-31T17:45:16Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Carl.Gould](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/carl.gould/32/7262_2.png) [@Carl.Gould](https://forum.inductiveautomation.com/u/Carl.Gould)\
**Post date:** [May 31, 2008, 6:57pm UTC](https://forum.inductiveautomation.com/t/drop-down-list/554/23 "2008-05-31T18:57:06Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![Step7](https://avatars.discourse-cdn.com/v4/letter/s/45deac/32.png) [@Step7](https://forum.inductiveautomation.com/u/Step7)\
**Post date:** [May 31, 2008, 7:13pm UTC](https://forum.inductiveautomation.com/t/drop-down-list/554/24 "2008-05-31T19:13:52Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Step7](https://avatars.discourse-cdn.com/v4/letter/s/45deac/32.png) [@Step7](https://forum.inductiveautomation.com/u/Step7)\
**Post date:** [June 22, 2008, 4:46pm UTC](https://forum.inductiveautomation.com/t/drop-down-list/554/25 "2008-06-22T16:46:05Z")

</div>

[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.

[Previous page](https://forum.inductiveautomation.com/t/drop-down-list/554.md?page=1)
