text: user2477: I failed to add Note=Gene description to mRNA attribute with the below code:
  #!/usr/bin/python3
  import click
  import gffutils
  import gffutils.gffwriter as gffwriter
  
  @click.command()
  @click.option('--gff3', help="Provide GFF3 file", required=True)
  @click.option('--keep', help="Keep GFF3 file", required=True)
  @click.option('--reject', help="Reject GFF3 file", required=True)
  def run(gff3, keep, reject):
      #db = gffutils.create_db(gff3, dbfn='data/test.db', force=True, keep_order=True, merge_strategy='merge',
      #                        sort_attribute_values=True)
  
      db = gffutils.FeatureDB('data/test.db', keep_order=True)
      for gene in db.features_of_type('gene', order_by='start'):
          print(gene)
          for i in db.children(gene, featuretype='mRNA', order_by='start'):
              print(i)
              print(i.id)
              print(i.attributes['Note']=["Gene description"])
              db.update([i])
  
  I got the following error:
  File "/projects/bioinf-scripts/mod_braker_gff3.py", line 20
      print(i.attributes['Note']=["Gene description"])
           ^
  SyntaxError: keyword can't be an expression
  
  What did I miss?
  Thank you in advance
  
  user298: You are printing the attribute before setting it, that's why it's complaining. So instead of this:
      print(i.attributes['Note']=["Gene description"])
  
  Set it first and then print:
  i.attributes['Note']=["Gene description"]
  print(i)
  
  
original_text: 2477: <p>I failed to add <code>Note=Gene description</code> to mRNA attribute with the below code:</p>
  
  <pre><code>#!/usr/bin/python3
  import click
  import gffutils
  import gffutils.gffwriter as gffwriter
  
  @click.command()
  @click.option('--gff3', help="Provide GFF3 file", required=True)
  @click.option('--keep', help="Keep GFF3 file", required=True)
  @click.option('--reject', help="Reject GFF3 file", required=True)
  def run(gff3, keep, reject):
      #db = gffutils.create_db(gff3, dbfn='data/test.db', force=True, keep_order=True, merge_strategy='merge',
      #                        sort_attribute_values=True)
  
      db = gffutils.FeatureDB('data/test.db', keep_order=True)
      for gene in db.features_of_type('gene', order_by='start'):
          print(gene)
          for i in db.children(gene, featuretype='mRNA', order_by='start'):
              print(i)
              print(i.id)
              print(i.attributes['Note']=["Gene description"])
              db.update([i])
  </code></pre>
  
  <p>I got the following error:</p>
  
  <pre><code>File "/projects/bioinf-scripts/mod_braker_gff3.py", line 20
      print(i.attributes['Note']=["Gene description"])
           ^
  SyntaxError: keyword can't be an expression
  </code></pre>
  
  <p>What did I miss?</p>
  
  <p>Thank you in advance</p>
   298: <p>You are printing the attribute before setting it, that's why it's complaining. So instead of this:</p>
  
  <pre><code>    print(i.attributes['Note']=["Gene description"])
  </code></pre>
  
  <p>Set it first and <em>then</em> print:</p>
  
  <pre><code>i.attributes['Note']=["Gene description"]
  print(i)
  </code></pre>
  