<div dir="ltr"><br><br><div class="gmail_quote">On Sat, Jul 26, 2008 at 10:23 PM, Marcus.CM <span dir="ltr"><<a href="mailto:marcus@internetnowasp.net">marcus@internetnowasp.net</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Well after reading some of these posts on "sacred python cow" on the "self" , i would generally feel that most programmers<br>
who started with C++/Java would find it odd. And its true, i agree completely there should not be a need to put "self" into every single<br>
member function. If you were writing an application and one of your classes adds the same variable to each of its member function you would do away with it too.<br>
What could be done instead is :-<br>
<br>
1. python should hardcode the keyword "self". So whenever this keyword is used, it would automatically implied that it is<br>
referring to a class scope variable. This would be similar to how the "this" keyword is used in C++.<br>
<br>
2. Omit self from the parameter.<br>
<br>
class Abc :<br>
     def  DoSomething (a,b,c) :<br>
           # class variable<br>
           self.somevar = a<br>
           self.someblar = b<br>
           self.somec = c<br>
           somevar = a * b  # local variable<div><div></div><div class="Wj3C7c"><br>
        <br>
</div></div></blockquote><div><br>So, what happens in this case, using your Abc class from before?<br><br><br>def DoTheSameThing(abc, a, b, c) :<br>    abc.somevar = a<br>    abc.someblar = b<br>    abc.somec = c<br>    somevar = a * b<br>
<br>Abc.DoSomething = DoTheSameThing<br><br>Would methods defined this way never have access to the class instance?<br><br></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div><div class="Wj3C7c"><br>
<br>
<br>
Russ P. wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
On Jul 26, 2:25 pm, Terry Reedy<br>
  <br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
There is a lot of code you have not seen.  Really.  In informal code I<br>
use 's' and 'o' for 'self' and 'other'.  I don't usually post such<br>
because it is not considered polite.  So you have seen a biased sample<br>
of the universe.<br>
    <br>
</blockquote>
<br>
You take the name down to a single letter. As I suggested in an<br>
earlier post on this thread, why not take it down to zero letters? You<br>
could if Python accepted something like<br>
<br>
class Whatever:<br>
<br>
    def fun( , cat):<br>
<br>
        .cat = cat<br>
<br>
This is even better than the single-character name, not only because<br>
it is shorter, but also because there is no question that you are<br>
referring to "self." No need to look back at the method signature to<br>
verify that.<br>
<br>
For those who don't like the way the empty first argument looks, maybe<br>
something like this could be allowed:<br>
<br>
    def fun( ., cat):<br>
<br>
--<br>
<a href="http://mail.python.org/mailman/listinfo/python-list" target="_blank">http://mail.python.org/mailman/listinfo/python-list</a><br>
<br>
  <br>
</blockquote>
<br>
<br>
--<br>
<a href="http://mail.python.org/mailman/listinfo/python-list" target="_blank">http://mail.python.org/mailman/listinfo/python-list</a><br>
</div></div></blockquote></div><br></div>