[Python-ideas] PEP: Shorthand Symbol for "self"

Russ Paielli russ.paielli at gmail.com
Mon Aug 25 13:19:08 CEST 2008

On Mon, Aug 25, 2008 at 12:45 AM, Bruce Leban <bruce at leapyear.org> wrote:

> Jim Jewett wrote:
> If I could write:
>   class foo:
>     def self.bar():
>       self.rebar(self.babar)
> then the call to  object.bar() would match the declaration.
> Back to Russ's proposal: it would be better accomodated IMHO by allowing $
> as a character in a variable name, just like _ is. Then, conventionally,
> people could use $ as self:
>   def $.bar():
>     $.rebar($.babar)
> and for whatever it's worth, I find $.bar easier to read then $bar as the
> explicit dot reminds me it's doing an attribute get rather than looking like
> a special variable name.

  def $.bar():

That's two separate proposals, but I think I like both of them.

Of course, Python already allows "S", which is very similar to "$", as the
first argument, so we're almost there on that aspect of it. Come to think of
it, I may start using "S" and see how it works out.

So how about

    def S.bar():

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20080825/e66c77cb/attachment.html>

More information about the Python-ideas mailing list