Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python and if statement

I'm running a script to feed an exe file a statement like below:

for j in ('90.','52.62263.','26.5651.','10.8123.'):
    if j == '90.':
        z = ('0.')
    elif j == '52.62263.':
        z = ('0.', '72.', '144.', '216.', '288.')
    elif j == '26.5651':
        z = ('324.', '36.', '108.', '180.', '252.')
    else:
        z = ('288.', '0.', '72.', '144.', '216.')

    for k in z:

        exepath = os.path.join('\Program Files' , 'BRL-CAD' , 'bin' , 'rtarea.exe')
        exepath = '"' + os.path.normpath(exepath) + '"'
        cmd = exepath + '-j' + str(el) + '-k' + str(z)

        process=Popen('echo ' + cmd, shell=True, stderr=STDOUT )
        print process

I'm using the command prompt and when I run the exe with these numbers there are times when It doesn't seem to be in order. Like sometimes it will print out 3 statements of the 52.62263 but then before they all are printed it will print out a single 26.5651 and then go back to 52.62263. It's not just those numbers that act like this. Different runs it may be different numbers (A 52.62263 between "two" 90 statements) . All in all, I want it to print it in order top to bottom. Any suggestions and using my code any helpful solutions? thanks!

like image 648
Tyler Avatar asked Dec 19 '25 03:12

Tyler


1 Answers

z = ('0.') is not a tuple, therefore your for k in z loop will iterate over the characters "0" and ".". Add a comma to tell python you want it to be a tuple:

z = ('0.',)
like image 52
eduffy Avatar answered Dec 20 '25 17:12

eduffy