Python Scripting Question

(BaDbOyHeRe) #1

I’m new to python and am having a little bit of a problem finding tutes relating to creating a loop. I have a plugin in mind and I need to have python import a file. My problem is that I need it to get the same file more than once, actually almost continously. I read somewhere awhile ago (cant recall exactly where) that you can perform the loop according to an event. How can I create a loop? Also, is it possible to have python compare changes within a file prior to getting it? example: have python compare the file’s modified date and time with the last one imported? This would be more desireable for the script to minimize cpu load. Any suggestions?


(theeth) #2

I’m pretty sure there are some functions in the os module (in the Python distro) to determines the time stamp of a file. As for creating loops, the keyword is while and it works like this:

Num = 1
<b>while</b> <i>Num &lt; 10</i>: # the part in italic is an argument that can be evaluated to true or false.
        Num += 1
        print Num

I hope that helps.


(BaDbOyHeRe) #3

I see, so the example you gave shows N with a starting point, then see if N is less than 10. finally, if true, print N? I will play with this until I get it right. Thank you for your help. I will post the script as soon as its working.