Re: [Pydev-users] Python program running twice
Brought to you by:
fabioz
From: Fabio Z. <fa...@gm...> - 2016-02-16 18:20:27
|
I don't think this is an issue in PyDev (I can't reproduce it and if something as grave was happening, I'm pretty sure there'd be other reports from it too). My guess is that you're doing an os.walk() which walks recursively and it's finding the name of the file more than once in a subdir and you're always applying it to the local file later on (you can just print your 'f' variable to know what it's finding). Best Regards, Fabio On Sun, Feb 14, 2016 at 9:24 PM, Gary Roach <gar...@ve...> wrote: > I've had several occasions when a python program seems to loop through > twice. Below is an example: > > from os import walk > import subprocess > > f = [] > x = "" > for (dirpath, dirnames, filenames) in walk('.'): > f.extend(filenames) > f.sort() > > for x in f: > if x[-3:]=='JPG': > print(x) > args = "convert " + x + " -rotate " + "-90 " + x > subprocess.call(args, shell=True) > > This program should rotate a jpg file by 90 degrees left. It actually > rotates the file 180 degrees and the print(x) function prints the file > name twice. What am I doming wrong. > > I run it as python rotate.py from the command line. > > Gary R. > > > > ------------------------------------------------------------------------------ > Site24x7 APM Insight: Get Deep Visibility into Application Performance > APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month > Monitor end-to-end web transactions and take corrective actions now > Troubleshoot faster and improve end-user experience. Signup Now! > http://pubads.g.doubleclick.net/gampad/clk?id=272487151&iu=/4140 > _______________________________________________ > Pydev-users mailing list > Pyd...@li... > https://lists.sourceforge.net/lists/listinfo/pydev-users > |