Re: Python Feature Request: Add the using keyword which works like with in Visual Basic

2007-04-16 Thread Colin J. Williams
James Stroud wrote: [EMAIL PROTECTED] wrote: Please check for sanity and approve for posting at python-dev. In Visual Basic there is the keyword with which allows an object- name to be declared as governing the following statements. For example: with quitCommandButton .enabled = true

Re: Python Feature Request: Add the using keyword which works like with in Visual Basic

2007-04-16 Thread Paul Boddie
[EMAIL PROTECTED] wrote: Please check for sanity and approve for posting at python-dev. Technically, you can post it yourself to python-dev, but you'll just get bounced back here to discuss it with us. ;-) In Visual Basic there is the keyword with which allows an object- name to be declared

Re: Python Feature Request: Add the using keyword which works like with in Visual Basic

2007-04-16 Thread Alex Martelli
Paul Boddie [EMAIL PROTECTED] wrote: Now I hear that the word with is being discussed for a different purpose in Py 3 as a result of a PEP and I don't want to conflict with that. The with keyword appears in 2.5 onwards. ...but needs a from __future__ import with_statement in 2.5 itself.

Python Feature Request: Add the using keyword which works like with in Visual Basic

2007-04-14 Thread samjnaa
Please check for sanity and approve for posting at python-dev. In Visual Basic there is the keyword with which allows an object- name to be declared as governing the following statements. For example: with quitCommandButton .enabled = true .default = true end with This is syntactic sugar for:

Re: Python Feature Request: Add the using keyword which works like with in Visual Basic

2007-04-14 Thread James Stroud
[EMAIL PROTECTED] wrote: Please check for sanity and approve for posting at python-dev. In Visual Basic there is the keyword with which allows an object- name to be declared as governing the following statements. For example: with quitCommandButton .enabled = true .default = true end

Re: Python Feature Request: Add the using keyword which works like with in Visual Basic

2007-04-14 Thread jamadagni
I like this one for some reason. Just the using self would save hella typing in a lot of classes. I would favor a convention with leading dots to disambiguate from other variables. This wouldn't conflict with, say, floats, because variable names can't begin with a number. Excellent. Now we

Re: Python Feature Request: Add the using keyword which works like with in Visual Basic

2007-04-14 Thread James Stroud
jamadagni wrote: I like this one for some reason. Just the using self would save hella typing in a lot of classes. I would favor a convention with leading dots to disambiguate from other variables. This wouldn't conflict with, say, floats, because variable names can't begin with a number.

Re: Python Feature Request: Add the using keyword which works like with in Visual Basic

2007-04-14 Thread James Stroud
jamadagni wrote: I like this one for some reason. Just the using self would save hella typing in a lot of classes. I would favor a convention with leading dots to disambiguate from other variables. This wouldn't conflict with, say, floats, because variable names can't begin with a number.

Re: Python Feature Request: Add the using keyword which works like with in Visual Basic

2007-04-14 Thread Duncan Booth
James Stroud [EMAIL PROTECTED] wrote: I like this one for some reason. Just the using self would save hella typing in a lot of classes. I would favor a convention with leading dots to disambiguate from other variables. This wouldn't conflict with, say, floats, because variable names can't

Re: Python Feature Request: Add the using keyword which works like with in Visual Basic

2007-04-14 Thread Bjoern Schliessmann
[EMAIL PROTECTED] wrote: In Visual Basic there is the keyword with which allows an object- name to be declared as governing the following statements. For example: with quitCommandButton .enabled = true .default = true end with This is syntactic sugar for:

Re: Python Feature Request: Add the using keyword which works like with in Visual Basic

2007-04-14 Thread jamadagni
On Apr 14, 5:06 pm, Duncan Booth [EMAIL PROTECTED] wrote: I can't see how it is going to save you any typing over what you can already do. The suggested example: The suggested example is only a small case. I realize that the main usage would be when there are a lot of repetitive usages when

Re: Python Feature Request: Add the using keyword which works like with in Visual Basic

2007-04-14 Thread jamadagni
Personally, I'd never use it. You are free to avoid using it of course. :) In more complex modules, when you are looking for, e. g., self.myVar and anotherObject.myVar, this using statement decreases readability and maintainability (in full text searching). IMHO. Why? Just search for self

Re: Python Feature Request: Add the using keyword which works like with in Visual Basic

2007-04-14 Thread BJörn Lindqvist
Your idea isn't new and has already been discussed lots of time before. It was once planned to be implemented in py3k, but no longer is. One of the problems is that with a using statement, you always have to decide whether your code repeats some prefix enough times to use a using statement.

Re: Python Feature Request: Add the using keyword which works like with in Visual Basic

2007-04-14 Thread jamadagni
You already can emulate the using statement like this: You can emulate only assignments like this. How would you emulate function calls, like the ones in my example? -- http://mail.python.org/mailman/listinfo/python-list

Re: Python Feature Request: Add the using keyword which works like with in Visual Basic

2007-04-14 Thread Mel Wilson
[EMAIL PROTECTED] wrote: In Visual Basic there is the keyword with which allows an object- name to be declared as governing the following statements. For example: with quitCommandButton .enabled = true .default = true end with This is syntactic sugar for:

Re: Python Feature Request: Add the using keyword which works like with in Visual Basic

2007-04-14 Thread Duncan Booth
BJörn Lindqvist [EMAIL PROTECTED] wrote: ? Not having to bother with petty things like that is an advantage. Javascript has with-statements that are equivalent to your using-statements but from what I've seen most programmers avoid them. They don't increase readability one bit. That is at

Re: Python Feature Request: Add the using keyword which works like with in Visual Basic

2007-04-14 Thread Duncan Booth
jamadagni [EMAIL PROTECTED] wrote: If you are going to reference self.quit a lot of times then it makes sense to also assign it to a local variable and then you already get even fewer characters (239): But you realize readability decreases considerably. Not as much as it would with your

Re: Python Feature Request: Add the using keyword which works like with in Visual Basic

2007-04-14 Thread BJörn Lindqvist
On 14 Apr 2007 07:24:32 -0700, jamadagni [EMAIL PROTECTED] wrote: You already can emulate the using statement like this: You can emulate only assignments like this. How would you emulate function calls, like the ones in my example? You can't, of course. But using the with statement: using

Re: Python Feature Request: Add the using keyword which works like with in Visual Basic

2007-04-14 Thread BJörn Lindqvist
On 4/14/07, BJörn Lindqvist [EMAIL PROTECTED] wrote: On 14 Apr 2007 07:24:32 -0700, jamadagni [EMAIL PROTECTED] wrote: You already can emulate the using statement like this: You can emulate only assignments like this. How would you emulate function calls, like the ones in my example?

Re: Python Feature Request: Add the using keyword which works like with in Visual Basic

2007-04-14 Thread 7stud
On Apr 14, 4:42 am, [EMAIL PROTECTED] wrote: This also is similar to the C++ using keyword which exposes the members of a namespace to access without specifying the namespace scope for each reference. For example after giving using namespace std; I can change all references to std::cout to

Re: Python Feature Request: Add the using keyword which works like with in Visual Basic

2007-04-14 Thread 7stud
On Apr 14, 12:57 pm, 7stud [EMAIL PROTECTED] wrote: On Apr 14, 4:42 am, [EMAIL PROTECTED] wrote: This also is similar to the C++ using keyword which exposes the members of a namespace to access without specifying the namespace scope for each reference. For example after giving using

Re: Python Feature Request: Add the using keyword which works like with in Visual Basic

2007-04-14 Thread Georg Brandl
BJörn Lindqvist schrieb: On 4/14/07, BJörn Lindqvist [EMAIL PROTECTED] wrote: On 14 Apr 2007 07:24:32 -0700, jamadagni [EMAIL PROTECTED] wrote: You already can emulate the using statement like this: You can emulate only assignments like this. How would you emulate function calls, like

Re: Python Feature Request: Add the using keyword which works like with in Visual Basic

2007-04-14 Thread Bjoern Schliessmann
jamadagni wrote: Bjoern Schliessmann wrote: In more complex modules, when you are looking for, e. g., self.myVar and anotherObject.myVar, this using statement decreases readability and maintainability (in full text searching). IMHO. Why? Just search for self and you turn up using self.

Re: Python Feature Request: Add the using keyword which works like with in Visual Basic

2007-04-14 Thread jamadagni
On Apr 15, 2:01 am, Bjoern Schliessmann usenet- [EMAIL PROTECTED] wrote: self.myVar -- something lost, something gained, IMHO. So, the gain is the loss of something different? If you say so. My mistake - I should have said no pain, no gain. IMHO, the ability to find something quickly

Re: Python Feature Request: Add the using keyword which works like with in Visual Basic

2007-04-14 Thread Steven D'Aprano
On Sat, 14 Apr 2007 03:42:52 -0700, samjnaa wrote: Please check for sanity and approve for posting at python-dev. In Visual Basic there is the keyword with which allows an object- name to be declared as governing the following statements. For example: with quitCommandButton .enabled =