[ python-Feature Requests-927543 ] "with self:" statement

SourceForge.net noreply at sourceforge.net
Thu Aug 25 09:59:33 CEST 2005


Feature Requests item #927543, was opened at 2004-04-01 16:36
Message generated for change (Settings changed) made by birkenfeld
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=355470&aid=927543&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: None
Group: None
>Status: Closed
>Resolution: Out of Date
Priority: 5
Submitted By: Thomas Dunne (tomdunne)
Assigned to: Nobody/Anonymous (nobody)
Summary: "with self:" statement

Initial Comment:
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...)



----------------------------------------------------------------------

>Comment By: Reinhold Birkenfeld (birkenfeld)
Date: 2005-08-25 09:59

Message:
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.

----------------------------------------------------------------------

Comment By: Raymond Hettinger (rhettinger)
Date: 2004-05-21 08:02

Message:
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.

----------------------------------------------------------------------

Comment By: Thomas Dunne (tomdunne)
Date: 2004-05-05 23:01

Message:
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...


----------------------------------------------------------------------

Comment By: Thomas Dunne (tomdunne)
Date: 2004-05-05 22:48

Message:
Logged In: YES 
user_id=1005553

Hey Greg,
thanks for the suggestion!
I posted a PEP to peps at python.org, flame on! ;)
(want a copy?)


----------------------------------------------------------------------

Comment By: Greg Ward (gward)
Date: 2004-05-05 03:45

Message:
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...)


----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=355470&aid=927543&group_id=5470


More information about the Python-bugs-list mailing list