<div dir="ltr">Just for fun, I made a copy of one of my Python files with hundreds of occurrences of "self", and I replaced them all with "S". This streamlines things significantly, and I think it looks good, but I suppose most Python aficionados would be aghast. I'm thinking about doing it permanently for all my files. I normally avoid single-character names, but I think this case could be a reasonable exception. What would you think if you saw this in "production" code?<br>
<br>--Russ<br><br><br><div class="gmail_quote">On Mon, Aug 25, 2008 at 3:35 AM, Brandon Mintern <span dir="ltr"><<a href="mailto:bmintern@gmail.com">bmintern@gmail.com</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;">
<div class="Ih2E3d">On Mon, Aug 25, 2008 at 3:45 AM, Bruce Leban <<a href="mailto:bruce@leapyear.org">bruce@leapyear.org</a>> wrote:<br>
> Jim Jewett wrote:<br>
> On Sun, Aug 24, 2008 at 6:26 PM, Terry Reedy <<a href="mailto:tjreedy@udel.edu">tjreedy@udel.edu</a>> wrote:<br>
>><br>
>> If m is an attribute of type(s) (which is s.__class__), this shrinkage is<br>
>> a convenient abbreviation, not a requirement. The above calls are the same<br>
>> as<br>
>> type(s).m(s.a,b,z) or type(s).m(s,a,b). Or, if you prefer,<br>
>> fn = type(s).m # or s.__class__.m<br>
>> fn(s,a,b,z)<br>
>> If m is an attribute s, and s in not a class, the shrinkage is not<br>
>> available, and one must write s.m(s,a,b,z) or s.m(s.a,b).<br>
>><br>
>> Terry Jan Reedy<br>
><br>
> If I could write:<br>
><br>
> class foo:<br>
> def self.bar():<br>
> self.rebar(self.babar)<br>
><br>
> then the call to object.bar() would match the declaration.<br>
<br>
</div>+1. I like this proposal: it's clean and sensible, and I think it<br>
looks a lot more clear, especially to someone who is new to Python.<br>
<div class="Ih2E3d"><br>
> Back to Russ's proposal: it would be better accomodated IMHO by allowing $<br>
> as a character in a variable name, just like _ is. Then, conventionally,<br>
> people could use $ as self:<br>
><br>
> def $.bar():<br>
> $.rebar($.babar)<br>
><br>
> and for whatever it's worth, I find $.bar easier to read then $bar as the<br>
> explicit dot reminds me it's doing an attribute get rather than looking like<br>
> a special variable name.<br>
<br>
</div>+1 I'm in agreement here as well. The closest I would get to<br>
supporting the $-for-self. proposal is allowing $ in variable names.<br>
Having used Lisp before Python, I'm used to just about any character<br>
being allowed in identifier names. The more characters available, the<br>
more expressive the names can be, and I think it could only help<br>
things. The overhead of people having to get used to new symbols being<br>
used in variable names would be small in comparison to the flexibility<br>
offered.<br>
<font color="#888888"><br>
Brandon<br>
</font><div><div></div><div class="Wj3C7c">_______________________________________________<br>
Python-ideas mailing list<br>
<a href="mailto:Python-ideas@python.org">Python-ideas@python.org</a><br>
<a href="http://mail.python.org/mailman/listinfo/python-ideas" target="_blank">http://mail.python.org/mailman/listinfo/python-ideas</a><br>
</div></div></blockquote></div><br><br clear="all"><br>-- <br><a href="http://RussP.us">http://RussP.us</a><br>
</div>