"self" inside plain function?
<p>I've got a bunch of functions (outside of any class) where I've set attributes on them, like <code>funcname.fields = 'xxx'</code>. I was hoping I could then access these variables from inside the function with <code>self.fields</code>, but of course it tells me:</p>

<blockquote>
  <p>global name 'self' is not defined</p>
</blockquote>

<p>So... what can I do? Is there some magic variable I can access? Like <code>__this__.fields</code>?</p>

<hr>

<p>A few people have asked "why?". You will probably disagree with my reasoning, but I have a set of functions that all must share the same signature (accept only one argument). For the most part, this one argument is enough to do the required computation. However, in a few limited cases, some additional information is needed. Rather than forcing every function to accept a long list of mostly unused variables, I've decided to just set them on the function so that they can easily be ignored. </p>

<p>Although, it occurs to me now that you could just use <code>**kwargs</code> as the last argument if you don't care about the additional args. Oh well...</p>

<p><strong>Edit:</strong> Actually, some of the functions I didn't write, and would rather not modify to accept the extra args. By "passing in" the additional args as attributes, my code can work both with my custom functions that take advantage of the extra args, and with third party code that don't require the extra args.</p>

<p>Thanks for the speedy answers :)</p>
