* Phillip J. Eby <[EMAIL PROTECTED]> [2007-12-08 20:19:29 -0500]:
> At 07:55 PM 12/8/2007 -0500, Manuel Alejandro Cerón Estrada wrote:
> >2007/12/8, Greg Ewing <[EMAIL PROTECTED]>:
> > > I would put it the other way around -- the problem
> > > that 'yield break' is meant to solve is already solved
At 07:55 PM 12/8/2007 -0500, Manuel Alejandro Cerón Estrada wrote:
>2007/12/8, Greg Ewing <[EMAIL PROTECTED]>:
> > I would put it the other way around -- the problem
> > that 'yield break' is meant to solve is already solved
> > by 'return'. So there's no need for change.
>
>I have been re-thinking
2007/12/8, Greg Ewing <[EMAIL PROTECTED]>:
> I would put it the other way around -- the problem
> that 'yield break' is meant to solve is already solved
> by 'return'. So there's no need for change.
I have been re-thinking the problem and this is true. The only
exception would be empty generators,
Manuel Alejandro Cerón Estrada wrote:
> Acording to PEP 255:
>
> Note that return isn't always equivalent to raising StopIteration: the
> difference lies in how enclosing try/except constructs are treated.
All that means is that
def g():
try:
if 0:
yield
At 12:30 PM 12/9/2007 +1300, Greg Ewing wrote:
>Terry Reedy wrote:
> > I would prefer plain 'yield' to 'yield break' as a synonym for 'raise
> > StopIteration'.
>
>Don't we already have a plain yield these days meaning
>something else?
Yes. It's equivalent to 'yield None'.
_
Manuel Alejandro Cerón Estrada wrote:
> The real problem is that
> raising StopIteration is not orthogonal.
This is a non-problem as far as I can see. In a generator,
the way to stop the iteration is simply to return. In a
non-generator iterator, you're still going to have to
raise StopIteration.
> 2007/12/8, Raymond Hettinger <[EMAIL PROTECTED]>:
>>...the proposal adds new syntax without adding functionality.
>
> That is indeed the definition of syntactic sugar [1]. Python is full
> of that, for example the import statement.
. . .
> The real problem is that
> raising StopIteration is not
Terry Reedy wrote:
> I would prefer plain 'yield' to 'yield break' as a synonym for 'raise
> StopIteration'.
Don't we already have a plain yield these days meaning
something else?
--
Greg
___
Python-Dev mailing list
Python-Dev@python.org
http://mail.p
2007/12/8, Raymond Hettinger <[EMAIL PROTECTED]>:
> In your example, why do you "raise StopIteration" instead just writing
> "return"?
In the example would be better to use 'return' rather than 'raise
StopIteration'. In most cases 'return' will have the same behavior
than 'raise StopIteration', b
Manuel Alejandro Cerón Estrada wrote:
> 2007/12/8, Raymond Hettinger <[EMAIL PROTECTED]>:
>> ...the proposal adds new syntax without adding functionality.
>
> That is indeed the definition of syntactic sugar [1]. Python is full
> of that, for example the import statement.
>
> 2007/12/8, Paul Sven
In your example, why do you "raise StopIteration" instead just writing "return"?
- Original Message -
From: "Manuel Alejandro Cerón Estrada" <[EMAIL PROTECTED]>
Take a look at this example:
def lines():
for line in my_file:
if some_error():
raise StopIteration()
2007/12/8, Raymond Hettinger <[EMAIL PROTECTED]>:
>...the proposal adds new syntax without adding functionality.
That is indeed the definition of syntactic sugar [1]. Python is full
of that, for example the import statement.
2007/12/8, Paul Svensson <[EMAIL PROTECTED]>:
> What is the problem that
I would prefer plain 'yield' to 'yield break' as a synonym for 'raise
StopIteration'.
But the raise stands out better visually as an exit point.
The point about the raise not being explicitly caught is not valid since
any generator could be used in the following code
g = some_gen
try:
while
> Note that 'yield break' resembles the 'break' statement used in loops,
> while 'StopIteration' doesn't. 'yield break' is more orthogonal to the
> rest of the language.
>
> I am looking forward to seeing your opinions.
-1
I do not find the meaning to be transparent and the proposal adds new synt
Hello Python developers.
This is my first post on the list. I have been using Python for a
while and I have been thinking about one feature I would like to see
integrated into the language. I thought it could be a good topic for a
PEP, so I decided to join the list and write about it.
First probl
15 matches
Mail list logo