On Mar 8, 2010, at 7:28 AM, Steve Holden wrote:
>>
>> But your response, both the out of context quoting and your comment,
>> seems solely designed to convey a negative impression instead of
>> addressing any technical issue.
>>
> This isn't an isolated case, Alf. Physician, heal thyself.
As fa
Alf P. Steinbach wrote:
> * Gabriel Genellina:
>> En Thu, 04 Mar 2010 20:52:04 -0300, Alf P. Steinbach
>> escribió:
>>
>>> Sorry, as with the places noted above, I can't understand what you're
>>> trying to say here.
>>
>> Regarding your posts, neither can I. All the time. Sorry, deciphering
>> yo
* Gabriel Genellina:
En Thu, 04 Mar 2010 20:52:04 -0300, Alf P. Steinbach
escribió:
Sorry, as with the places noted above, I can't understand what you're
trying to say here.
Regarding your posts, neither can I. All the time. Sorry, deciphering
your posts would force me to spend much more t
En Thu, 04 Mar 2010 20:52:04 -0300, Alf P. Steinbach
escribió:
Sorry, as with the places noted above, I can't understand what you're
trying to say here.
Regarding your posts, neither can I. All the time. Sorry, deciphering your
posts would force me to spend much more time than available
* Robert Kern:
On 2010-03-03 09:39 AM, Mike Kent wrote:
What's the compelling use case for this vs. a simple try/finally?
original_dir = os.getcwd()
try:
os.chdir(somewhere)
# Do other stuff
finally:
os.chdir(original_dir)
# Do other cleanup
A custo
* Steve Howell:
On Mar 3, 7:10 am, "Alf P. Steinbach" wrote:
For C++ Petru Marginean once invented the "scope guard" technique (elaborated on
by Andrei Alexandrescu, they published an article about it in DDJ) where all you
need to do to ensure some desired cleanup at the end of a scope, even wh
* Mike Kent:
On Mar 4, 8:04 pm, Robert Kern wrote:
No, the try: finally: is not implicit. See the source for
contextlib.GeneratorContextManager. When __exit__() gets an exception from the
with: block, it will push it into the generator using its .throw() method. This
raises the exception insid
On 2010-03-05 10:29 AM, Mike Kent wrote:
On Mar 4, 8:04 pm, Robert Kern wrote:
No, the try: finally: is not implicit. See the source for
contextlib.GeneratorContextManager. When __exit__() gets an exception from the
with: block, it will push it into the generator using its .throw() method. Thi
On Mar 4, 5:04 pm, Robert Kern wrote:
> On 2010-03-04 15:19 PM, Mike Kent wrote:
>
>
>
> > On Mar 3, 12:00 pm, Robert Kern wrote:
> >> On 2010-03-03 09:39 AM, Mike Kent wrote:
>
> >>> What's the compelling use case for this vs. a simple try/finally?
>
> >>> original_dir = os.getcwd()
> >>>
On Mar 5, 8:29 am, Mike Kent wrote:
> On Mar 4, 8:04 pm, Robert Kern wrote:
>
> > No, the try: finally: is not implicit. See the source for
> > contextlib.GeneratorContextManager. When __exit__() gets an exception from
> > the
> > with: block, it will push it into the generator using its .throw(
On Mar 4, 8:04 pm, Robert Kern wrote:
> No, the try: finally: is not implicit. See the source for
> contextlib.GeneratorContextManager. When __exit__() gets an exception from the
> with: block, it will push it into the generator using its .throw() method.
> This
> raises the exception inside the
* Robert Kern:
On 2010-03-04 16:27 , Alf P. Steinbach wrote:
* Mike Kent:
However, I fail to understand his response that I must have meant try/
else instead, as this, as Mr. Kern pointed out, is invalid syntax.
Perhaps Mr. Steinbach would like to give an example?
OK.
Assuming that you wan
* Robert Kern:
On 2010-03-04 17:52 , Alf P. Steinbach wrote:
* Robert Kern:
On 2010-03-04 12:37 PM, Alf P. Steinbach wrote:
* Robert Kern:
On 2010-03-04 10:56 AM, Alf P. Steinbach wrote:
* Robert Kern:
On 2010-03-03 18:49 PM, Alf P. Steinbach wrote:
[snippety]
If you call the possibly fa
Robert Kern wrote:
On 2010-03-04 15:12 , Mike Kent wrote:
On Mar 4, 12:30 pm, Robert Kern wrote:
He's ignorant of the use cases of the with: statement, true.
Ouch! Ignorant of the use cases of the with statement, am I?
Odd, I use it all the time.
No, I was referring to Jean-Michel, who
On 2010-03-04 17:52 , Alf P. Steinbach wrote:
* Robert Kern:
On 2010-03-04 12:37 PM, Alf P. Steinbach wrote:
* Robert Kern:
On 2010-03-04 10:56 AM, Alf P. Steinbach wrote:
* Robert Kern:
On 2010-03-03 18:49 PM, Alf P. Steinbach wrote:
[snippety]
If you call the possibly failing operation
On 2010-03-04 15:12 , Mike Kent wrote:
On Mar 4, 12:30 pm, Robert Kern wrote:
He's ignorant of the use cases of the with: statement, true.
Ouch! Ignorant of the use cases of the with statement, am I?
Odd, I use it all the time.
No, I was referring to Jean-Michel, who was not familiar wi
On 2010-03-04 16:27 , Alf P. Steinbach wrote:
* Mike Kent:
However, I fail to understand his response that I must have meant try/
else instead, as this, as Mr. Kern pointed out, is invalid syntax.
Perhaps Mr. Steinbach would like to give an example?
OK.
Assuming that you wanted the chdir to
On Mar 3, 7:10 am, "Alf P. Steinbach" wrote:
> For C++ Petru Marginean once invented the "scope guard" technique (elaborated
> on
> by Andrei Alexandrescu, they published an article about it in DDJ) where all
> you
> need to do to ensure some desired cleanup at the end of a scope, even when the
* Steve Holden:
Alf P. Steinbach wrote:
* Robert Kern:
[...]
No, it only argues that "with Cleanup():" is supernumerary.
I don't know what "supernumerary" means, but to the degree that the
argument says anything about a construct that is not 'finally', it says
the same about general "with".
On 2010-03-04 15:19 PM, Mike Kent wrote:
On Mar 3, 12:00 pm, Robert Kern wrote:
On 2010-03-03 09:39 AM, Mike Kent wrote:
What's the compelling use case for this vs. a simple try/finally?
original_dir = os.getcwd()
try:
os.chdir(somewhere)
# Do other stuff
f
Alf P. Steinbach wrote:
> * Robert Kern:
[...]
>> No, it only argues that "with Cleanup():" is supernumerary.
>
> I don't know what "supernumerary" means, but to the degree that the
> argument says anything about a construct that is not 'finally', it says
> the same about general "with".
>
So rat
* Robert Kern:
On 2010-03-04 12:37 PM, Alf P. Steinbach wrote:
* Robert Kern:
On 2010-03-04 10:56 AM, Alf P. Steinbach wrote:
* Robert Kern:
On 2010-03-03 18:49 PM, Alf P. Steinbach wrote:
[snippety]
If you call the possibly failing operation "A", then that systematic
approach goes like t
On 2010-03-04 12:37 PM, Alf P. Steinbach wrote:
* Robert Kern:
On 2010-03-04 10:56 AM, Alf P. Steinbach wrote:
* Robert Kern:
On 2010-03-03 18:49 PM, Alf P. Steinbach wrote:
[snippety]
If you call the possibly failing operation "A", then that systematic
approach goes like this: if A fails,
* Mike Kent:
On Mar 4, 12:30 pm, Robert Kern wrote:
He's ignorant of the use cases of the with: statement, true.
Ouch! Ignorant of the use cases of the with statement, am I?
Odd, I use it all the time.
Given only your
example of the with: statement, it is hard to fault him for thinking
On Mar 3, 12:00 pm, Robert Kern wrote:
> On 2010-03-03 09:39 AM, Mike Kent wrote:
>
> > What's the compelling use case for this vs. a simple try/finally?
>
> > original_dir = os.getcwd()
> > try:
> > os.chdir(somewhere)
> > # Do other stuff
> > finally:
> > os.c
On Mar 4, 12:30 pm, Robert Kern wrote:
> He's ignorant of the use cases of the with: statement, true.
Ouch! Ignorant of the use cases of the with statement, am I?
Odd, I use it all the time.
> Given only your
> example of the with: statement, it is hard to fault him for thinking that try:
>
On Mar 3, 10:56 am, "Alf P. Steinbach" wrote:
> * Mike Kent:
>
> > What's the compelling use case for this vs. a simple try/finally?
>
> if you thought about it you would mean a simple "try/else". "finally" is
> always
> executed. which is incorrect for cleanup
>
> by the way, that's one advantag
* Robert Kern:
On 2010-03-04 10:56 AM, Alf P. Steinbach wrote:
* Robert Kern:
On 2010-03-03 18:49 PM, Alf P. Steinbach wrote:
[snippety]
If you call the possibly failing operation "A", then that systematic
approach goes like this: if A fails, then it has cleaned up its own
mess, but if A su
Michael Rudolf wrote:
Am 04.03.2010 17:32, schrieb Jean-Michel Pichavant:
It looks like to me that 'with' statements are like decorators:
overrated.
Oh no, you just insulted my favourite two python features, followed
immediately by generators, iterators and list comprehensions /
generator ex
Am 04.03.2010 18:20, schrieb Robert Kern:
What I'm trying to explain is that the with: statement has a use even if
Cleanup doesn't. Arguing that Cleanup doesn't improve on try: finally:
does not mean that the with: statement doesn't improve on try: finally:.
Yes, the with-statement rocks :)
I
Am 04.03.2010 17:32, schrieb Jean-Michel Pichavant:
It looks like to me that 'with' statements are like decorators: overrated.
Oh no, you just insulted my favourite two python features, followed
immediately by generators, iterators and list comprehensions / generator
expressions :p
No, real
On 2010-03-04 11:02 AM, Alf P. Steinbach wrote:
* Robert Kern:
On 2010-03-04 09:48 AM, Alf P. Steinbach wrote:
* Jean-Michel Pichavant:
Alf P. Steinbach wrote:
From your post, the scope guard technique is used "to ensure some
desired cleanup at the end of a scope, even when the scope is exite
On 2010-03-04 10:56 AM, Alf P. Steinbach wrote:
* Robert Kern:
On 2010-03-03 18:49 PM, Alf P. Steinbach wrote:
* Robert Kern:
[snip]
can you
understand why we might think that you were saying that try: finally:
was wrong and that you were proposing that your code was equivalent to
some try: e
* Robert Kern:
On 2010-03-04 09:48 AM, Alf P. Steinbach wrote:
* Jean-Michel Pichavant:
Alf P. Steinbach wrote:
From your post, the scope guard technique is used "to ensure some
desired cleanup at the end of a scope, even when the scope is exited
via an exception." This is precisely what the t
On 2010-03-04 10:32 AM, Jean-Michel Pichavant wrote:
Alf P. Steinbach wrote:
* Jean-Michel Pichavant:
Alf P. Steinbach wrote:
From your post, the scope guard technique is used "to ensure some
desired cleanup at the end of a scope, even when the scope is
exited via an exception." This is precis
* Robert Kern:
On 2010-03-03 18:49 PM, Alf P. Steinbach wrote:
* Robert Kern:
[snip]
can you
understand why we might think that you were saying that try: finally:
was wrong and that you were proposing that your code was equivalent to
some try: except: else: suite?
No, not really. His code d
Alf P. Steinbach wrote:
* Jean-Michel Pichavant:
Alf P. Steinbach wrote:
From your post, the scope guard technique is used "to ensure some
desired cleanup at the end of a scope, even when the scope is
exited via an exception." This is precisely what the try: finally:
syntax is for.
You'd
On 2010-03-04 09:48 AM, Alf P. Steinbach wrote:
* Jean-Michel Pichavant:
Alf P. Steinbach wrote:
From your post, the scope guard technique is used "to ensure some
desired cleanup at the end of a scope, even when the scope is exited
via an exception." This is precisely what the try: finally: syn
* Jean-Michel Pichavant:
Alf P. Steinbach wrote:
From your post, the scope guard technique is used "to ensure some
desired cleanup at the end of a scope, even when the scope is exited
via an exception." This is precisely what the try: finally: syntax is
for.
You'd have to nest it. That's u
On 2010-03-03 18:49 PM, Alf P. Steinbach wrote:
* Robert Kern:
On 2010-03-03 15:35 PM, Alf P. Steinbach wrote:
* Robert Kern:
On 2010-03-03 13:32 PM, Alf P. Steinbach wrote:
* Robert Kern:
On 2010-03-03 11:18 AM, Alf P. Steinbach wrote:
* Robert Kern:
On 2010-03-03 09:56 AM, Alf P. Steinba
Alf P. Steinbach wrote:
From your post, the scope guard technique is used "to ensure some
desired cleanup at the end of a scope, even when the scope is exited
via an exception." This is precisely what the try: finally: syntax is
for.
You'd have to nest it. That's ugly. And more importantly,
* Robert Kern:
On 2010-03-03 15:35 PM, Alf P. Steinbach wrote:
* Robert Kern:
On 2010-03-03 13:32 PM, Alf P. Steinbach wrote:
* Robert Kern:
On 2010-03-03 11:18 AM, Alf P. Steinbach wrote:
* Robert Kern:
On 2010-03-03 09:56 AM, Alf P. Steinbach wrote:
* Mike Kent:
What's the compelling us
On 2010-03-03 15:35 PM, Alf P. Steinbach wrote:
* Robert Kern:
On 2010-03-03 13:32 PM, Alf P. Steinbach wrote:
* Robert Kern:
On 2010-03-03 11:18 AM, Alf P. Steinbach wrote:
* Robert Kern:
On 2010-03-03 09:56 AM, Alf P. Steinbach wrote:
* Mike Kent:
What's the compelling use case for this
* Robert Kern:
On 2010-03-03 13:32 PM, Alf P. Steinbach wrote:
* Robert Kern:
On 2010-03-03 11:18 AM, Alf P. Steinbach wrote:
* Robert Kern:
On 2010-03-03 09:56 AM, Alf P. Steinbach wrote:
* Mike Kent:
What's the compelling use case for this vs. a simple try/finally?
if you thought about
On 2010-03-03 13:32 PM, Alf P. Steinbach wrote:
* Robert Kern:
On 2010-03-03 11:18 AM, Alf P. Steinbach wrote:
* Robert Kern:
On 2010-03-03 09:56 AM, Alf P. Steinbach wrote:
* Mike Kent:
What's the compelling use case for this vs. a simple try/finally?
if you thought about it you would mea
On Wed, Mar 3, 2010 at 2:32 PM, Alf P. Steinbach wrote:
> I'm not sure what that shows, except that you haven't grokked this yet.
Maybe you could give us an example of how your code should be used,
and how it differs from the other examples people have given? And
maybe a quick example of why you
* Robert Kern:
On 2010-03-03 11:18 AM, Alf P. Steinbach wrote:
* Robert Kern:
On 2010-03-03 09:56 AM, Alf P. Steinbach wrote:
* Mike Kent:
What's the compelling use case for this vs. a simple try/finally?
if you thought about it you would mean a simple "try/else".
"finally" is
always exec
On 2010-03-03 11:18 AM, Alf P. Steinbach wrote:
* Robert Kern:
On 2010-03-03 09:56 AM, Alf P. Steinbach wrote:
* Mike Kent:
What's the compelling use case for this vs. a simple try/finally?
if you thought about it you would mean a simple "try/else". "finally" is
always executed. which is inc
* Robert Kern:
On 2010-03-03 09:56 AM, Alf P. Steinbach wrote:
* Mike Kent:
What's the compelling use case for this vs. a simple try/finally?
if you thought about it you would mean a simple "try/else". "finally" is
always executed. which is incorrect for cleanup
Eh? Failed execution doesn't
* Robert Kern:
On 2010-03-03 09:39 AM, Mike Kent wrote:
What's the compelling use case for this vs. a simple try/finally?
original_dir = os.getcwd()
try:
os.chdir(somewhere)
# Do other stuff
finally:
os.chdir(original_dir)
# Do other cleanup
A custo
On 2010-03-03 09:56 AM, Alf P. Steinbach wrote:
* Mike Kent:
What's the compelling use case for this vs. a simple try/finally?
if you thought about it you would mean a simple "try/else". "finally" is
always executed. which is incorrect for cleanup
Eh? Failed execution doesn't require cleanup
On 2010-03-03 09:39 AM, Mike Kent wrote:
What's the compelling use case for this vs. a simple try/finally?
original_dir = os.getcwd()
try:
os.chdir(somewhere)
# Do other stuff
finally:
os.chdir(original_dir)
# Do other cleanup
A custom-written contex
* Mike Kent:
What's the compelling use case for this vs. a simple try/finally?
if you thought about it you would mean a simple "try/else". "finally" is always
executed. which is incorrect for cleanup
by the way, that's one advantage:
a "with Cleanup" is difficult to get wrong, while a "try"
What's the compelling use case for this vs. a simple try/finally?
original_dir = os.getcwd()
try:
os.chdir(somewhere)
# Do other stuff
finally:
os.chdir(original_dir)
# Do other cleanup
--
http://mail.python.org/mailman/listinfo/python-list
For C++ Petru Marginean once invented the "scope guard" technique (elaborated on
by Andrei Alexandrescu, they published an article about it in DDJ) where all you
need to do to ensure some desired cleanup at the end of a scope, even when the
scope is exited via an exception, is to declare a Scope
55 matches
Mail list logo