zipher <dreamingforw...@gmail.com>:

> Would it be prudent to rid the long-standing "argument" (pun
> unintended) about self and the ulterior spellings of it, by changing
> it into a symbol rather than a name?
>
> Something like:
>
> class MyClass(object):
>
>     def __init__(@):
>         @.dummy = None
>
> OR, even better, getting *rid of it* in the parameter list, so it
> stops confusing people about how many parameters a method needs, and
> transform it into a true *operator*.

Python's practice works. However, a small problem is presented by nested
classes:

    class Connection:
        def __init__(self):
            class Idle:
                def signal_start(self):
                    # how to refer to the outer self
                    :
            :

Solutions include:

    class Connection:
        def __init__(self):
            class Idle:
                def signal_start(_):
                    self.set_state(Ready)
            :


    class Connection:
        def __init__(self):
            conn = self
            class Idle:
                def signal_start(self):
                    conn.set_state(Ready)
            :


I have used the latter method recently.


Marko
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to