title: How to write OS X Finder Comments from python?
body: <p>I'm working on a python script that creates numerous images files based on a variety of inputs in OS X Yosemite. I am trying to write the inputs used to create each file as 'Finder comments' as each file is created so that IF the the output is visually interesting I can look at the specific input values that generated the file.  I've verified that this can be done easily with apple script. </p>
  
  <p><code>tell application "Finder" to set comment of (POSIX file "/Users/mgarito/Desktop/Random_Pixel_Color/2015-01-03_14.04.21.png" as alias) to {Val1, Val2, Val3} as Unicode text</code></p>
  
  <p>Afterward, upon selecting the file and showing its info (cmd+i) the Finder comments clearly display the expected text 'Val1, Val2, Val2'.</p>
  
  <p>This is further confirmed by running mdls [File/Path/Name] before and after the applescript is used which clearly shows the expected text has been properly added. </p>
  
  <p>The problem is I can't figure out how to incorporate this into my python script to save myself.</p>
  
  <p>Im under the impression the solution should* be something to the effect of:<code>
  VarList = [Var1, Var2, Var3]
  Fiele = [File/Path/Name]
  file.os.system.add(kMDItemFinderComment, VarList)</code></p>
  
  <p>As a side note I've also look at xattr -w [Attribute_Name] [Attribute_Value] [File/Path/Name] but found that though this will store the attribute, it is not stored in the desired location. Instead it ends up in an affiliated pList which is not what I'm after.</p>