title: In Python, is there a compact way to print the names of those variables in a list that meet a condition?
body: <p>I'm writing some printouts for the debug mode of a script. Is there a compact way to print the names of those variables in a list that meet a condition?</p>
  
  <pre><code>specification_aw3 = 43534
  specification_hg7 = 75445
  specification_rt5 = 0
  specification_nj8 = 5778
  specification_lo4 = 34
  specification_ee2 = 8785
  specification_ma2 = 67
  specification_pw1 = 1234
  specification_mu6 = 0
  specification_xu8 = 12465
  
  specifications = [
      specification_aw3,
      specification_hg7,
      specification_rt5,
      specification_nj8,
      specification_lo4,
      specification_ee2,
      specification_ma2,
      specification_pw1,
      specification_mu6,
      specification_xu8
  ]
  
  if any(specification == 0 for specification in specifications):
      # magic code to print variables' names
      # e.g. "variables equal to 0: \"specification_rt5\", \"specification_mu6\"
  </code></pre>
  
  <p>Just as 9000 <a href="https://stackoverflow.com/a/42140440/1556092">suggests</a>, it goes without saying that defining a dictionary is a rational approach for the minimal working example I have defined here. Please assume that this is not a feasible option for the existing code project and that I am looking for a quick, compact (plausibly ugly) bit of code to be used solely for debugging.</p>
  
  <hr>
  
  <p>EDIT: illustration of something similar to what I want</p>
  
  <p>So here's the beginnings of what I'm looking for:</p>
  
  <pre><code>print("specifications equal to zero:")
  callers_local_objects = inspect.currentframe().f_back.f_locals.items()
  for specification in [specification for specification in specifications if specification == 0]:
      print([object_name for object_name, object_instance in callers_local_objects if object_instance is specification][0])
  </code></pre>
  
  <p>Basically, is there a compact way to do something like this?</p>