Python Feature Request: Add the "using" keyword which works like "with" in Visual Basic
g.brandl at gmx.net
Sat Apr 14 22:46:33 CEST 2007
BJörn Lindqvist schrieb:
> On 4/14/07, BJörn Lindqvist <bjourne at gmail.com> wrote:
>> On 14 Apr 2007 07:24:32 -0700, jamadagni <samjnaa at gmail.com> 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 self.q:
>> with self.quit as q:
> Er.. I guess there are some details you need to work out for that. But
> in principle, it works fine.
No, it does not. The "q" here is *not* assigned to self.quit, but to the
result of self.quit.__enter__().
Thus spake the Lord: Thou shalt indent with four spaces. No more, no less.
Four shall be the number of spaces thou shalt indent, and the number of thy
indenting shall be four. Eight shalt thou not indent, nor either indent thou
two, excepting that thou then proceed to four. Tabs are right out.
More information about the Python-list