title: What is the best practice to do with temporary (unused) list?
body: <p>I've a code snippet below which gets the dataclass variables (keys) with &quot;_dg&quot; prefix, then gets the attribute of each key according to declaration order and appends them into a list. At the end this will be merged into a single element and returned as a string.</p>
  <pre><code>def create_decrypted_EFSOD(self) -&gt; str:
  
      _ = []
      try:
          for attr in list(self.__dict__.keys()):
              if attr.startswith(&quot;_dg&quot;):
                  _.append(self.__getattribute__(attr))
  
          return &quot;&quot;.join(_)
  
      finally:
          del _ 
  </code></pre>
  <p>Where my dataclass is declared as:</p>
  <pre><code>@dataclass
  class PassiveAuthenticator:
      &quot;&quot;&quot;
      Passive Authentication of eMRTD Documents for Inspection Systems (IFD's). Protects against IC forging.
  
      Refers to &quot;Doc. 9303, Machine Readable Travel Documents, Part 11 - Security Mechanisms for MRTDS&quot; by ICAO, 2021,
      Section 6.1 and Appendix G for more details about security protocols.
  
      &quot;&quot;&quot;
      _dg1: str
      _dg2: str
      _dg3: str
      .
      .
      
  </code></pre>
  <p>I know the <code>_</code> variable always refers to last returned value, that is why I used it to avoid creating unnecessary variable, but creating a temporary variable still bothers me. <strong>What is the best practice for this situation?</strong></p>
  <p>Also, does deleting <code>_</code> variable mean anything since it'll be redeclared again? Since I'm a C++ dev it's a habit to deallocate.</p>