<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comentarios en: Programación Temporal de Eventos con Python</title>
	<atom:link href="http://www.juanjoconti.com.ar/2006/09/11/programacion-temporal-de-eventos-con-python/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.juanjoconti.com.ar/2006/09/11/programacion-temporal-de-eventos-con-python/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=programacion-temporal-de-eventos-con-python</link>
	<description>el blog de Juanjo Conti - abstracto, lúdico y digital</description>
	<lastBuildDate>Tue, 07 Feb 2012 01:36:00 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=</generator>
	<item>
		<title>Por: Juanjo</title>
		<link>http://www.juanjoconti.com.ar/2006/09/11/programacion-temporal-de-eventos-con-python/comment-page-1/#comment-1502</link>
		<dc:creator>Juanjo</dc:creator>
		<pubDate>Sat, 16 Sep 2006 14:00:35 +0000</pubDate>
		<guid isPermaLink="false">http://firebirds.com.ar/~juanjo/wordpress/2006/09/11/programacion-temporal-de-eventos-con-python/#comment-1502</guid>
		<description>Me quedó la duda de si lo de -1, 0 y 1 me lo había imaginado o realmente había leido que debía ser así:

&lt;pre&gt;
&gt;&gt;&gt; help([].sort)
Help on built-in function sort:

sort(...)
    L.sort(cmpfunc=None) -- stable sort *IN PLACE*; cmpfunc(x, y) -&gt; -1, 0, 1
&lt;/pre&gt;

Lo había leido, de todas formas la otra forma también funciona:

&lt;pre&gt;
&gt;&gt;&gt; l = range(10)
&gt;&gt;&gt; l
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
&gt;&gt;&gt; l.sort(lambda a, b: b - a)
&gt;&gt;&gt; l
[9, 8, 7, 6, 5, 4, 3, 2, 1, 0]
&gt;&gt;&gt; l.reverse()    # hace lo mismo que el sort tuneado de más arriba
&gt;&gt;&gt; l
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
&lt;/pre&gt;
</description>
		<content:encoded><![CDATA[<p>Me quedó la duda de si lo de -1, 0 y 1 me lo había imaginado o realmente había leido que debía ser así:</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;"><span style="color: #66cc66;">&gt;&gt;&gt;</span> <span style="color: #008000;">help</span><span style="color: black;">&#40;</span><span style="color: black;">&#91;</span><span style="color: black;">&#93;</span>.<span style="color: black;">sort</span><span style="color: black;">&#41;</span>
Help on built-<span style="color: #ff7700;font-weight:bold;">in</span> function sort:
&nbsp;
sort<span style="color: black;">&#40;</span>...<span style="color: black;">&#41;</span>
    L.<span style="color: black;">sort</span><span style="color: black;">&#40;</span>cmpfunc=<span style="color: #008000;">None</span><span style="color: black;">&#41;</span> -- stable sort <span style="color: #66cc66;">*</span>IN PLACE<span style="color: #66cc66;">*;</span> cmpfunc<span style="color: black;">&#40;</span>x, y<span style="color: black;">&#41;</span> -<span style="color: #66cc66;">&gt;</span> -<span style="color: #ff4500;">1</span>, <span style="color: #ff4500;">0</span>, <span style="color: #ff4500;">1</span></pre></div></div>

<p>Lo había leido, de todas formas la otra forma también funciona:</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;"><span style="color: #66cc66;">&gt;&gt;&gt;</span> l = <span style="color: #008000;">range</span><span style="color: black;">&#40;</span><span style="color: #ff4500;">10</span><span style="color: black;">&#41;</span>
<span style="color: #66cc66;">&gt;&gt;&gt;</span> l
<span style="color: black;">&#91;</span><span style="color: #ff4500;">0</span>, <span style="color: #ff4500;">1</span>, <span style="color: #ff4500;">2</span>, <span style="color: #ff4500;">3</span>, <span style="color: #ff4500;">4</span>, <span style="color: #ff4500;">5</span>, <span style="color: #ff4500;">6</span>, <span style="color: #ff4500;">7</span>, <span style="color: #ff4500;">8</span>, <span style="color: #ff4500;">9</span><span style="color: black;">&#93;</span>
<span style="color: #66cc66;">&gt;&gt;&gt;</span> l.<span style="color: black;">sort</span><span style="color: black;">&#40;</span><span style="color: #ff7700;font-weight:bold;">lambda</span> a, b: b - a<span style="color: black;">&#41;</span>
<span style="color: #66cc66;">&gt;&gt;&gt;</span> l
<span style="color: black;">&#91;</span><span style="color: #ff4500;">9</span>, <span style="color: #ff4500;">8</span>, <span style="color: #ff4500;">7</span>, <span style="color: #ff4500;">6</span>, <span style="color: #ff4500;">5</span>, <span style="color: #ff4500;">4</span>, <span style="color: #ff4500;">3</span>, <span style="color: #ff4500;">2</span>, <span style="color: #ff4500;">1</span>, <span style="color: #ff4500;">0</span><span style="color: black;">&#93;</span>
<span style="color: #66cc66;">&gt;&gt;&gt;</span> l.<span style="color: black;">reverse</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>    <span style="color: #808080; font-style: italic;"># hace lo mismo que el sort tuneado de más arriba</span>
<span style="color: #66cc66;">&gt;&gt;&gt;</span> l
<span style="color: black;">&#91;</span><span style="color: #ff4500;">0</span>, <span style="color: #ff4500;">1</span>, <span style="color: #ff4500;">2</span>, <span style="color: #ff4500;">3</span>, <span style="color: #ff4500;">4</span>, <span style="color: #ff4500;">5</span>, <span style="color: #ff4500;">6</span>, <span style="color: #ff4500;">7</span>, <span style="color: #ff4500;">8</span>, <span style="color: #ff4500;">9</span><span style="color: black;">&#93;</span></pre></div></div>

]]></content:encoded>
	</item>
	<item>
		<title>Por: Juanjo</title>
		<link>http://www.juanjoconti.com.ar/2006/09/11/programacion-temporal-de-eventos-con-python/comment-page-1/#comment-1501</link>
		<dc:creator>Juanjo</dc:creator>
		<pubDate>Sat, 16 Sep 2006 05:04:38 +0000</pubDate>
		<guid isPermaLink="false">http://firebirds.com.ar/~juanjo/wordpress/2006/09/11/programacion-temporal-de-eventos-con-python/#comment-1501</guid>
		<description>Gracias Daniel! mejoro el código con tu consejo!

Juanjo

PS: si, salió bien. Pero te cambié las marcas &lt;code&gt; por &lt;pre&gt; para que se respete el indentado en el código.</description>
		<content:encoded><![CDATA[<p>Gracias Daniel! mejoro el código con tu consejo!</p>
<p>Juanjo</p>
<p>PS: si, salió bien. Pero te cambié las marcas &lt;code> por &lt;pre> para que se respete el indentado en el código.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Por: Daniel Moisset</title>
		<link>http://www.juanjoconti.com.ar/2006/09/11/programacion-temporal-de-eventos-con-python/comment-page-1/#comment-1500</link>
		<dc:creator>Daniel Moisset</dc:creator>
		<pubDate>Fri, 15 Sep 2006 23:00:20 +0000</pubDate>
		<guid isPermaLink="false">http://firebirds.com.ar/~juanjo/wordpress/2006/09/11/programacion-temporal-de-eventos-con-python/#comment-1500</guid>
		<description>Se puede simplificar un poco la función de comparación. Los valores de resultado no necesariamente deben ser -1, 0 y +1, alcanza con que devuelvas negativo, 0, positivo. con lo que podés hacer:

&lt;pre&gt;
def _comparar_tiempos(a,b):
    &quot;&quot;&quot; Función auxiliar usada para ordenar los pares eventos,tiempos
    en la lista de eventos.
    &quot;&quot;&quot;
    t1 = a[1]
    t2 = b[1]
    return t1 - t2
&lt;/pre&gt;

y cuando se simplifica tanto, por ahí podrías no definirla y directamente usar:

&lt;pre&gt;
eventos.sort (lambda e1,e2:e1[1]-e2[1])
&lt;/pre&gt;

que es una función que hace lo mismo pero con notación lambda la ponés inline...

[espero que esto quede bien, no hay botón de preview]</description>
		<content:encoded><![CDATA[<p>Se puede simplificar un poco la función de comparación. Los valores de resultado no necesariamente deben ser -1, 0 y +1, alcanza con que devuelvas negativo, 0, positivo. con lo que podés hacer:</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;"><span style="color: #ff7700;font-weight:bold;">def</span> _comparar_tiempos<span style="color: black;">&#40;</span>a,b<span style="color: black;">&#41;</span>:
    <span style="color: #483d8b;">&quot;&quot;&quot; Función auxiliar usada para ordenar los pares eventos,tiempos
    en la lista de eventos.
    &quot;&quot;&quot;</span>
    t1 = a<span style="color: black;">&#91;</span><span style="color: #ff4500;">1</span><span style="color: black;">&#93;</span>
    t2 = b<span style="color: black;">&#91;</span><span style="color: #ff4500;">1</span><span style="color: black;">&#93;</span>
    <span style="color: #ff7700;font-weight:bold;">return</span> t1 - t2</pre></div></div>

<p>y cuando se simplifica tanto, por ahí podrías no definirla y directamente usar:</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;">eventos.<span style="color: black;">sort</span> <span style="color: black;">&#40;</span><span style="color: #ff7700;font-weight:bold;">lambda</span> e1,e2:e1<span style="color: black;">&#91;</span><span style="color: #ff4500;">1</span><span style="color: black;">&#93;</span>-e2<span style="color: black;">&#91;</span><span style="color: #ff4500;">1</span><span style="color: black;">&#93;</span><span style="color: black;">&#41;</span></pre></div></div>

<p>que es una función que hace lo mismo pero con notación lambda la ponés inline&#8230;</p>
<p>[espero que esto quede bien, no hay botón de preview]</p>
]]></content:encoded>
	</item>
	<item>
		<title>Por: Milton</title>
		<link>http://www.juanjoconti.com.ar/2006/09/11/programacion-temporal-de-eventos-con-python/comment-page-1/#comment-1494</link>
		<dc:creator>Milton</dc:creator>
		<pubDate>Mon, 11 Sep 2006 18:05:08 +0000</pubDate>
		<guid isPermaLink="false">http://firebirds.com.ar/~juanjo/wordpress/2006/09/11/programacion-temporal-de-eventos-con-python/#comment-1494</guid>
		<description>Muy bueno el post. Que bueno estaría mas adelante poder utilizar estos conocimientos de simulación adquiridos para algún proyecto. Lo mismo digo con lo que estamos aprendiendo en Sistemas de Gestión I.

También muy interesante (cada vez más), Python...</description>
		<content:encoded><![CDATA[<p>Muy bueno el post. Que bueno estaría mas adelante poder utilizar estos conocimientos de simulación adquiridos para algún proyecto. Lo mismo digo con lo que estamos aprendiendo en Sistemas de Gestión I.</p>
<p>También muy interesante (cada vez más), Python&#8230;</p>
]]></content:encoded>
	</item>
</channel>
</rss>

