@TGV said:
@jetcitywoman said:
@forkazoo said:
if not globalSettings.noDaily != False:
I'd like it better this way, for pure sadistic pleasure.
You know you have to remove the not, right? So
if (globalSettings.noDaily != False) != True
is much better.
I'm glad to know I'm not the only one who thinks it should be False in order to maintain the weir rhythm of the line. Here is another excerpt from it. It's actually two lines of code, so it isn't quite as dense, but it still shows some of the character without really posting too much. Showing some of the repetetive Pokemon exception handling would simply be too lengthy and dull to be entertaining.
print "INSERT INTO Look_{0}_shots (Shot_Numb,Shot_Seq,Shot_jobName,Shot_Durat,Shot_Etat,Shot_TcIN,Shot_RefFrame,Shot_TcFrRate) \
VALUES ('{1}','{2}','{3}',{4},'Offline','{5}',{6},'{7}')".format(jobNumb,leJob.shotname,leJob.scene,leJob.shot,leclip.duration(),\
leclip.fileAttrib.tc,leclip.frame('in'),leJob.jobDetail.fps
)
cursor.execute("INSERT INTO Look_{0}_shots (Shot_Numb,Shot_Seq,Shot_jobName,Shot_Durat,Shot_Etat,Shot_TcIN,Shot_RefFrame,Shot_TcFrRate) \
VALUES ('{1}','{2}','{3}',{4},'Offline','{5}',{6},'{7}')".format(jobNumb,leJob.shotname,leJob.scene,leJob.shot,leclip.duration(),\
leclip.fileAttrib.tc,leclip.frame('in'),leJob.jobDetail.fps
))
I'm going to start by ignoring the fact that an SQL query is constructed manually. This isn't web code, and in this context it isn't really a security issue vulnerable to injection. It's a python script with a abked in username and password, so anybody who can run it can trivially pwn the DB. Instead, I'll draw your attention to printing the query string for debugging purposes, but instead of stuffing the query into a variable and the printing and executing it, we construct the query in two separate places, guaranteeing that as you debug it, you will eventually get these two lines out of sync at some point. In the string formatting to build the query string, you also have one hard coded value in the middle of the substitutions, so that the list of columns and the list of variables to stuff int those columns are *almost* the same. And of course, the fun mixing of under_scores and camelCase, English and French, occasional definite articles, which make a veritable smorgasboard of variable naming conventions. Almost no two variable are ever named according to exactly the same logic anywhere in the project.