title: How do I reference the object passed to my class when I instantiate?
body: <p>I have this class</p>
  
  <pre><code>class SECHeader(object):
      def __init__(self,header_path):
          self.header = open(header_path).read()
  </code></pre>
  
  <p>I have some methods in this class, one of the methods I am trying to do needs to parse the name  </p>
  
  <pre><code>        def parsed_name(self):
              return header_path.split('-')[-1]
  </code></pre>
  
  <p>This works fine if in my code I use the name header_path to identify the thing I am trying to operate on</p>
  
  <pre><code>for header_path in header_paths:
         header = SECHeader(header_path)
         print header.parsed_name()
  </code></pre>
  
  <p>But if I change the name</p>
  
  <pre><code>for named_path in header_paths:
         header = SECHeader(named_path)
         print header.parsed_name()
  </code></pre>
  
  <p>I get a NameError</p>
  
  <p>I played around - if can use any name for the object in the parsed_name function as long as I use the same name for the object I want to process but I can't seem to figure out how to name it so a user does not have to use my naming scheme</p>
  
  <p>specifically if I change the parsed_name function to </p>
  
  <pre><code>        def parsed_name(self):
              return banana.split('-')[-1]
  </code></pre>
  
  <p>and in my loop if change it to </p>
  
  <pre><code>for banana in header_paths:
      header = SECHeader(banana)
      print header.parsed_name()
  </code></pre>
  
  <p>it works like a charm but that limits the portability of this thing I am working on. as any user would have to reference the path with whatever label I use in the function.</p>