Terry Reedy wrote:
> "Alexander Myodov" <[EMAIL PROTECTED]> wrote in message
> news:[EMAIL PROTECTED]
> > and even list comprehensions:
> > b1 = [l for l in a1]
> > print "l: %s" % l
>
> This will go away in 3.0. For now, del l if you wish.
Or use a generator expression:
>>> b1 = list(l for l
"Alexander Myodov" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Hello,
> for k in a1:
>pass
> print "k: %s" % k
> where "k" lives long after the actual need in it was lost,
There are occasions, especially when one breaks out of the loop, when
keeping k bound *is* useful.
Alexander Myodov wrote:
> Or maybe you have an idea how this can be fixed? The
> simplest way I see is putting all the "controlled" variables into a
> dedicated class... and do that each time for each block of variables I
> need control lifetime. Is there any simpler way?
I wouldn't use the word
Alexander Myodov wrote:
> Sorry, I misworded the question - RIIA is indeed present at least by
> the reason that the examples from PEP pass. Agree, my problem is a bit
> different, and I a bit mixed up initialization/acquisition with
> lifetime blocks. So, seems that we indeed have one and still do
>> No, it means that Python 2.5 supports 'resource initialisation is
>> acquisition', but that has nothing to do with the restricting the
>> lifetime of a variable.
> Sorry, I misworded the question - RIIA is indeed present at least by
> the reason that the examples from PEP pass. Agree, my problem
Hello Duncan,
You wrote:
> Alexander Myodov wrote:
>> So, with 2.5, I tried to utilize "with...as" construct for this, but
>> unsuccessfully:
>> ...
>> So, does this mean that we still don't have any kind of RIIA in
>> Python, any capability to localize the lifetime of variables on a
>> level less
Alexander Myodov wrote:
> So, with 2.5, I tried to utilize "with...as" construct for this, but
> unsuccessfully:
>from __future__ import with_statement
>with 5 as k:
> pass
>print k
> - told me that "AttributeError: 'int' object has no attribute
> '__context__'".
>
>
> So, does
Hello,
Having heard that Python 2.5 offers some kind of RIIA concept via
PEP343, got it downloaded (Windows version) and tried. But it did not
work as expected and as wanted.
For the time since I first learned Python, the only reason why I just
could not use it was inability to localize the lifeti