Help, re SMTP posting / RFC822

Phil Mayes nospam at bitbucket.com
Sat Sep 18 01:29:19 EDT 1999


Benjamin Schollnick wrote in message ...
>   def return_message (self):
>      tmp_message = ''
>      tmp_message = to_text + ' ' + from_text + ' '
>        +body_sep + to_text + ' ' + from_text +  subject_text + body_text
>      return tmp_message
>
> On this routine, I was getting name lookup errors, until I changed
>the references to include "self.",
> which makes some degree of sense.  But then, I was getting Attribute
>Errors, until I changed all the
> other calls in the module to be self's.
>
> It makes sense, but I was suprised that I would manually (via self)
>have to tell python that the data
> is from the object's local namespace, instead of it automatically
>recognizing that.  (Ala Borland Pascal)

Yes, you do have to - it's the equivalent of C++'s this.  Again, guaranteed
to bite a few times before becoming intuitive.  My common error was:
    ...
    self.x = 3
    ...
    x = 7
    ...
    if self.x == 7: # WHAT?! why doesn't this succeed ?!
The above creates a separate variable x that is local to the member
function.
--
Phil Mayes    pmayes AT olivebr DOT com







More information about the Python-list mailing list