msg54135 - (view) |
Author: Thomas Dunne (tomdunne) |
Date: 2004-04-01 14:36 |
please forgive if this is documented somewhere; I looked and searched and could not find any up to date PEPs or comments about the status of this idea. I managed to find a thread from 2002 that talked about this in great detail: http://mail.python.org/pipermail/python-list/2002-July/112888.html but there was no conclusion... I know it's not a new idea and it shows up often... but here goes: How about a "with self:" statement, but more in the style of (forgive) VB then Pascal, ie referenced items in the self instance are preceded with a dot. present syntax: with self: returnvalue = self.x + self.y * self.width proposed syntax: with self: returnvalue = .x + .y * .width If no preceding dot is used, you run into an ambiguity when assigning values. How do you know if the variable is to be assigned in self or to an object in a higher scope... the preceding dot avoids that problem since it explicitly tags self items. (using nested "with" statements will lead to the same problem when assigning values. Assignment will have to be to the innermost "with object". Reading values should work ok though. ) I understand that I could just simply use "s." instead of "self." or assign all needed values in one preceding line: x,y,width = self.x, self.y, self.width This is a question that shows up every so often, the points made in the thread are good: http://mail.python.org/pipermail/python-list/2002-July/113831.html has this been recently discussed? is there a patch or PEP? (I might be able to provide a patch...) |
|
|
msg54136 - (view) |
Author: Greg Ward (gward)  |
Date: 2004-05-05 01:45 |
Logged In: YES user_id=14422 A change of this magnitude demands a PEP. I don't recall having seen one, but I haven't been following python-dev for a while. If you want to do the right thing, write up a PEP and submit it to python-dev for the obligatory shooting-down-in-flames. Document the reasons why the feature was rejected in the PEP, and then the next time someone asks for it, your PEP can be trotted out. And don't take it personally when your idea gets shot down in flames. (Heck, who knows, maybe the python-dev crew will latch on and someone will implement it. But I doubt it...) |
|
|
msg54137 - (view) |
Author: Thomas Dunne (tomdunne) |
Date: 2004-05-05 20:48 |
Logged In: YES user_id=1005553 Hey Greg, thanks for the suggestion! I posted a PEP to peps@python.org, flame on! ;) (want a copy?) |
|
|
msg54138 - (view) |
Author: Thomas Dunne (tomdunne) |
Date: 2004-05-05 21:01 |
Logged In: YES user_id=1005553 Hey Greg, completely OT, but thought you should know: your sourceforge address redirect isn't correct! I sent an email to gward at users.sourceforge.net and the host (don't want to post for everyone to see here) responded that the redirected address didn't exist... |
|
|
msg54139 - (view) |
Author: Raymond Hettinger (rhettinger) *  |
Date: 2004-05-21 06:02 |
Logged In: YES user_id=80475 Guido occasionally mentions this as a possibility, so writing a PEP would be a useful next step. Though simple, this would change the feel of the language. Accordingly, it would need much public discussion before advancing. |
|
|
msg54140 - (view) |
Author: Georg Brandl (georg.brandl) *  |
Date: 2005-08-25 07:59 |
Logged In: YES user_id=1188172 As "with" is taken now, this is out of date. If you find another reasonable keyword, feel free to reopen, but keep in mind that it still needs a PEP. |
|
|