[Python-Dev] reducing self.x=x; self.y=y; self.z=z boilerplate code (original) (raw)
Reinhold Birkenfeld reinhold-birkenfeld-nospam at wolke7.net
Sat Jul 2 09:02:52 CEST 2005
- Previous message: [Python-Dev] reducing self.x=x; self.y=y; self.z=z boilerplate code
- Next message: [Python-Dev] reducing self.x=x; self.y=y; self.z=z boilerplate code
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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!
- Previous message: [Python-Dev] reducing self.x=x; self.y=y; self.z=z boilerplate code
- Next message: [Python-Dev] reducing self.x=x; self.y=y; self.z=z boilerplate code
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]