A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2005-July/054582.html below:

[Python-Dev] reducing self.x=x; self.y=y; self.z=z boilerplate code

[Python-Dev] reducing self.x=x; self.y=y; self.z=z boilerplate codeReinhold Birkenfeld reinhold-birkenfeld-nospam at wolke7.net
Sat Jul 2 09:02:52 CEST 2005
Nick Coghlan wrote:

[...]

> If the right hand side of 'as' permitted the same forms as are going 
> to be permitted for the 'as' clause in 'with' statements, then Ralf's 
> situation could be handled via:
> 
>    def __init__(self as s, x as s.x, y as s.y, z as s.z):
>       pass
> 
> Essentially, it allows arguments to be given two names - a public name 
> (before the 'as', used for keyword arguments), and a private name 
> (after the 'as', not used for keyword arguments, allows easy shorthand 
> aliasing of self, unpacking of tuple arguments, and easy assignment of 
> instance variables).

There once was a suggestion like this on c.l.py, expanding this to other
statements, like:

if re.match('a.*b', text) as m:
    # do something

What has become of this? It seems to be a wanted feature, and while I concur
that classic 'C-style' assignment-as-expression is undesirable (because of
the =/== bug-source), this would be a way, wouldn't it?

Reinhold

-- 
Mail address is perfectly valid!

More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4