A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2003-October/039384.html below:

[Python-Dev] PEP 289: Generator Expressions

[Python-Dev] PEP 289: Generator ExpressionsSkip Montanaro skip at pobox.com
Thu Oct 23 11:48:15 EDT 2003
    Guido> No, I meant that "for x.a in mylist: ..." is valid but shouldn't
    Guido> be,

Valid?  I'll buy that, but it had never occurred to me.  Useful?  That's not
immediately obvious:

    >>> class Foo:
    ...   def __init__(self):
    ...     self.a = 42
    ... 
    >>> lst = [Foo() for i in range(4)]
    >>> lst
    [<__main__.Foo instance at 0x752760>, <__main__.Foo instance at
    0x7529e0>, <__main__.Foo instance at 0x752df0>, <__main__.Foo instance
    0x7529e0>at 0x752dc8>] 
    >>> [x for x.a in lst]
    [Type help() for interactive help, or help(object) for help about
    object., Type help() for interactive help, or help(object) for help
    about object., Type help() for interactive help, or help(object) for
    help about object., Type help() for interactive help, or help(object)
    for help about object.] 

Skip

More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4