<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">Il giorno 03 ottobre 2013 16:26, Remo The Last <span dir="ltr"><<a href="mailto:py.remothelast@yahoo.it" target="_blank">py.remothelast@yahoo.it</a>></span> ha scritto:<br>
<br></div><div class="gmail_quote">premetto che non conosco telnetlib, ad ogni modo ...<br><br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div><div style="font-size:12pt;font-family:times new roman,new york,times,serif"><div style="font-style:normal;font-size:16px;background-color:transparent;font-family:times new roman,new york,times,serif"></div><div style="font-style:normal;font-size:16px;background-color:transparent;font-family:times new roman,new york,times,serif">
1° listato funzionante</div><div style="font-style:normal;font-size:16px;background-color:transparent;font-family:times new roman,new york,times,serif">contatore = 0<br></div><div style="font-style:normal;font-size:16px;background-color:transparent;font-family:times new roman,new york,times,serif">
while contatore <= 10:</div><div style="font-style:normal;font-size:16px;background-color:transparent;font-family:times new roman,new york,times,serif"><span>    </span><span>conn = telnetlib.Telnet(address,23,3)</span><span></span><br>
<span>    contatore += 1</span></div><div style="font-style:normal;font-size:16px;background-color:transparent;font-family:times new roman,new york,times,serif"><span>    </span>...<br></div></div></div></blockquote><div>
<br></div><div>occhio che qui riassegni conn quindi perdi tutte le precedenti e rimane solo l'ultima<br><span><br></span></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div><div style="font-size:12pt;font-family:times new roman,new york,times,serif"><div style="font-style:normal;font-size:16px;background-color:transparent;font-family:times new roman,new york,times,serif"><span></span></div>
<div style="font-style:normal;font-size:16px;background-color:transparent;font-family:times new roman,new york,times,serif">E' ovvio che non posso chiamare dieci connessioni tutte con il nome 'conn'. E' sbagliato!<br>
<span>(naturalmente 'address' è differente ad ogni iterazione del while sennò rischio un auto-DoS)</span></div><div style="font-style:normal;font-size:16px;background-color:transparent;font-family:times new roman,new york,times,serif">
<span><br></span></div><span>2° listato che mi si impalla<br></span><div style="font-style:normal;font-size:16px;background-color:transparent;font-family:times new roman,new york,times,serif"><span>conn = []</span></div><div style="font-style:normal;font-size:16px;background-color:transparent;font-family:times new roman,new york,times,serif">
<span>contatore = 0</span></div><div style="font-style:normal;font-size:16px;background-color:transparent;font-family:times new roman,new york,times,serif"><span>while contatore <= 10:</span><br><span>    conn[contatore] = telnetlib.Telnet(address,23,7)</span><br>
<span>    contatore += 1<br></span></div></div></div></blockquote><div><br></div><div>qui ne apri effettivamente 10<br></div><div>però sarebbe molto più pythonico scrivere<br>conn = [ <span>telnetlib.Telnet(address,23,7) for idx in range(10) ]</span> <br>
</div></div><br></div><div class="gmail_extra">Marco<br></div></div>