PEP 289: Generator Expressions (please comment)

Rocco Moretti roccomoretti at hotpop.com
Wed Oct 29 10:04:54 EST 2003


Alex Martelli wrote:

>>"""
>>[x for x in S]    # This is a list comprehension.
>>[(x for x in S)]  # This is a list containing one generator
>>                   # expression.
>>"""
>>*and* the former is depreciated in favor of list(<genex>).
> 
> 
> I think the spelling is "deprecated" -- and while I'd love it
> to be, I don't think it is.

Aha, yes.

 From dictionary.com (Quoting the American Heritage Dictionary):

"""
de·pre·ci·ate:
    1.  To lessen the price or value of.
    2. To think or speak of as being of little worth; belittle. See 
Usage Note at deprecate.

dep·re·cate:
    1. To express disapproval of; deplore.
    2. To belittle; depreciate.

     Usage Note: The first and fully accepted meaning of deprecate is 
“to express disapproval of.” But the word has steadily encroached on the 
meaning of depreciate. It is now used, almost to the exclusion of 
depreciate, in the sense “to belittle or mildly disparage,” as in He 
deprecated his own contribution. In an earlier survey, this newer sense 
was approved by a majority of the Usage Panel.
"""

Deprecate also has an additional technical usage entry from the Jargon File.

And you are right on the deprecated status. Quoth the PEP:

"""
List comprehensions will remain unchanged. For example:

[x for x in S]    # This is a list comprehension.
[(x for x in S)]  # This is a list containing one generator
                   # expression.

Unfortunately, there is currently a slight syntactic difference. The 
expression:

[x for x in 1, 2, 3]

is legal, meaning:

[x for x in (1, 2, 3)]

But generator expressions will not allow the former version:

(x for x in 1, 2, 3)

is illegal.

The former list comprehension syntax will become illegal in Python 3.0, 
and should be deprecated in Python 2.4 and beyond.
"""

I originally misread this. It should mean:
[x for x in 1, 2, 3] - is deprecated.
[x for x in (1, 2, 3)] - remains valid.

-Rocco





More information about the Python-list mailing list