<div dir="ltr">Ciao Luca,<div><br></div><div>non ho controllato, ma "a naso" direi che un generatore, anche se definito in line è un oggetto function, e come tale ha il suo namespace chiuso che non può accedere all'esterno.</div><div>per usare un generatore in un contesto simile potresti fare una cosa così:</div><div>def iter_orari(self):</div><div><span style="font-size:12.8px;font-family:monospace,monospace"> for s in sorted(self.orario.settimane):</span></div><div><span style="font-size:12.8px;font-family:monospace,monospace"> yield </span><span style="font-family:monospace,monospace;font-size:12.8px">self.orario.settimane[s]</span><span style="font-family:monospace,monospace;font-size:12.8px"> </span></div><div><span style="font-family:monospace,monospace;font-size:12.8px"><br></span></div><div><span style="font-size:12.8px;font-family:monospace,monospace">for o in </span>iter_orari(self):</div><div> print o</div></div><div class="gmail_extra"><br><div class="gmail_quote">Il giorno 18 gennaio 2018 16:29, Luca <span dir="ltr"><<a href="mailto:luca800@gmail.com" target="_blank">luca800@gmail.com</a>></span> ha scritto:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><span class=""><div class="gmail_extra"><div class="gmail_quote">Il giorno 18 gennaio 2018 16:27, Luca <span dir="ltr"><<a href="mailto:luca800@gmail.com" target="_blank">luca800@gmail.com</a>></span> ha scritto:<br clear="all"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div><div><div><br><span style="font-family:monospace,monospace">for o in (self.orario.settimane[s] for s in sorted(self.orario.settimane)]</span><span style="font-family:monospace,monospace"><wbr>): <br> print o</span><br></div></div></div></div></blockquote></div><br clear="all"><br></div></span><div class="gmail_extra">scusate era:<br><br><span style="font-family:monospace,monospace">for o in (self.orario.settimane[s] for s in sorted(self.orario.settimane)</span><span style="font-family:monospace,monospace">)<wbr>: <br> print o</span></div><span class="HOEnZb"><font color="#888888"><div class="gmail_extra"><br>-- <br><div class="m_7732782662871741039gmail_signature"><div dir="ltr"><div>Luca</div></div></div>
</div></font></span></div>
<br>______________________________<wbr>_________________<br>
Python mailing list<br>
<a href="mailto:Python@lists.python.it">Python@lists.python.it</a><br>
<a href="https://lists.python.it/mailman/listinfo/python" rel="noreferrer" target="_blank">https://lists.python.it/<wbr>mailman/listinfo/python</a><br>
<br></blockquote></div><br></div>