[Python] vobject.readcomponents(...) : Is it a generator or does it *return* a generator?

Discussão em 'Python' iniciado por Stack, Setembro 5, 2025.

  1. Stack

    Stack Membro Participativo

    This is a question about technical terminology.

    The vobject documentation says "readComponents is a generator", which is consistent with its doc string "Generate one Component at a time from a stream".

    However, the sample code vobject.readComponents(icalstream).next().vevent.dtstart.value shows that readComponents(...) returns a generator, as does the example code here: for c in vobject.readComponents(vcfs):.

    It makes a difference. Repeatedly invoking a method that returns a generator simply recreates the generator anew.

    Is the reference to vobject.readComponents as a generator simply a case of speaking loosely, i.e., it actually returns a generator?

    Continue reading...

Compartilhe esta Página