yield from () Was: Re: weirdness with list()
Alan Gauld
alan.gauld at yahoo.co.uk
Mon Mar 1 19:07:27 EST 2021
On 28/02/2021 23:47, Alan Gauld via Python-list wrote:
> On 28/02/2021 00:17, Cameron Simpson wrote:
>
>> BUT... It also has a __iter__ value, which like any Box iterates over
>> the subboxes. For MDAT that is implemented like this:
>>
>> def __iter__(self):
>> yield from ()
>
> Sorry, a bit OT but I'm curious. I haven't seen
> this before:
>
> yield from ()
>
> What is it doing?
> What do the () represent in this context?
>
Thanks for the replies.
I should have known better but I was thinking some
cleverness with callables and completely forgot
the empty tuple syntax. Oops!
--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos
More information about the Python-list
mailing list