Explicit Frustration of the Self

Terry Hancock hancock at anansispaceworks.com
Sun Jan 5 04:03:50 EST 2003


On Saturday 04 January 2003 10:08 pm,  Courageous wrote:
> >This whole business with the self; it is not elegant.
> 
> This is an entirely subjective matter, elegance. Take
> the penchant of many windows programmers using C++ who
> put m_ before all their member variables. This is really
> just the programmer working around ambiguity. In my mind,
> *that* is inelegant.
> 
> In python 'm_' is spelled 'self'.

But actually, you can* spell it anyway you like, e.g.:

class ham:
    def __init__(self):
        self.spam = 'Spam, spam, ... wonderful spam!'

class ham:
    def __init__(this):
        this.spam = 'Still yummy, but C-ish'

class ham:
    def __init__(m_):
        m_.spam = 'Just following your lead.'

class ham:
    def __init__(my):
        my.spam = 'Ouch, I broke my tooth on a perl!'

class ham:
    def __init__(_):
         _.spam = 'Nearly invisible.'

class ham:
    def __init__(object_specific_variable):
        object_specific_variable.spam = 'This is just silly' 

>>> ham = ham()
>>> ham.spam
'This is just silly'

It doesn't seem necessary to alter the language to do this,
especially since it would tick-off a lot of existing developers.

Cheers,
Terry

*Okay, maybe I _shouldn't_ have mentioned this, because frankly, if
you do this to _me_, I'm going to have to bludgeon you with a rubber
chicken.

--
Terry Hancock ( hancock at anansispaceworks.com )
Anansi Spaceworks  http://www.anansispaceworks.com

"Some things are too important to be taken seriously"





More information about the Python-list mailing list