<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Python-cj25</title>
	<atom:link href="http://pycj.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://pycj.wordpress.com</link>
	<description>todo lo que voy aprendiendo en Python</description>
	<lastBuildDate>Thu, 05 Jan 2012 22:02:09 +0000</lastBuildDate>
	<language>es</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='pycj.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://1.gravatar.com/blavatar/b4c8eb37c379b2ecf85341d90b153d69?s=96&#038;d=http%3A%2F%2Fs2.wp.com%2Fi%2Fbuttonw-com.png</url>
		<title>Python-cj25</title>
		<link>http://pycj.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://pycj.wordpress.com/osd.xml" title="Python-cj25" />
	<atom:link rel='hub' href='http://pycj.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Python Everywhere</title>
		<link>http://pycj.wordpress.com/2011/03/18/python-everywhere/</link>
		<comments>http://pycj.wordpress.com/2011/03/18/python-everywhere/#comments</comments>
		<pubDate>Fri, 18 Mar 2011 16:17:55 +0000</pubDate>
		<dc:creator>Carlos Joel</dc:creator>
				<category><![CDATA[Humor]]></category>

		<guid isPermaLink="false">http://pycj.wordpress.com/?p=108</guid>
		<description><![CDATA[Python Everywhere<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=pycj.wordpress.com&amp;blog=8684468&amp;post=108&amp;subd=pycj&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><a href="http://pycj.files.wordpress.com/2011/03/python-python-everywhere.jpg"><img class="alignleft size-thumbnail wp-image-109" title="Python-Python-everywhere" src="http://pycj.files.wordpress.com/2011/03/python-python-everywhere.jpg?w=150&#038;h=83" alt="" width="150" height="83" /></a></p>
<p>Python Everywhere</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/pycj.wordpress.com/108/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/pycj.wordpress.com/108/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/pycj.wordpress.com/108/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/pycj.wordpress.com/108/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/pycj.wordpress.com/108/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/pycj.wordpress.com/108/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/pycj.wordpress.com/108/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/pycj.wordpress.com/108/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/pycj.wordpress.com/108/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/pycj.wordpress.com/108/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/pycj.wordpress.com/108/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/pycj.wordpress.com/108/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/pycj.wordpress.com/108/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/pycj.wordpress.com/108/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=pycj.wordpress.com&amp;blog=8684468&amp;post=108&amp;subd=pycj&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://pycj.wordpress.com/2011/03/18/python-everywhere/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/d0fa25be2c38f9394f97011524c5c387?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">carlosj2585</media:title>
		</media:content>

		<media:content url="http://pycj.files.wordpress.com/2011/03/python-python-everywhere.jpg?w=150" medium="image">
			<media:title type="html">Python-Python-everywhere</media:title>
		</media:content>
	</item>
		<item>
		<title>Variables &#8211; Parte 3</title>
		<link>http://pycj.wordpress.com/2009/11/14/variables-parte-3/</link>
		<comments>http://pycj.wordpress.com/2009/11/14/variables-parte-3/#comments</comments>
		<pubDate>Sun, 15 Nov 2009 04:45:14 +0000</pubDate>
		<dc:creator>Carlos Joel</dc:creator>
				<category><![CDATA[Variables]]></category>

		<guid isPermaLink="false">http://pycj.wordpress.com/2009/11/14/variables-parte-3/</guid>
		<description><![CDATA[En esta parte me enfocaré a lo que se conoce como «Tipado dinámico» de las variables, ya que Python es un lenguaje de «Tipado Dinámico» y además «Fuertemente Tipado», lo que veremos a continuación: Tipado Dinámico Esta característica se refiere a que no es necesario declarar el tipo de dato que se almacenan en las [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=pycj.wordpress.com&amp;blog=8684468&amp;post=87&amp;subd=pycj&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<div>
<p style="margin-bottom:0;font-weight:normal;text-align:justify;"><span style="font-family:FreeSans,sans-serif;">En esta parte me enfocaré a lo que se conoce como «Tipado dinámico» de las variables, ya que Python es un lenguaje de  <em><strong>«Tipado Dinámico»</strong></em> y además  <em><strong>«Fuertemente Tipado»</strong></em><span style="font-style:normal;">, lo que veremos a continuación:</span></span></p>
<p style="margin-bottom:0;font-weight:normal;text-align:justify;">
<h2 style="margin-bottom:0;text-align:justify;"><span style="font-family:FreeSans,sans-serif;"><span style="text-decoration:underline;"><strong><span style="font-style:normal;">Tipado Dinámico</span></strong></span></span></h2>
<p style="margin-bottom:0;font-weight:normal;text-align:justify;"><span style="font-family:FreeSans,sans-serif;"><span style="font-style:normal;">Esta característica se refiere a que no es necesario declarar el tipo de dato que se almacenan en las variables, como en el caso de otros lenguajes, sino que su tipo se determinará en tiempo de ejecución, de acuerdo al valor que se le asigne, así que es posible que el tipo de la variable cambie de acuerdo al valor que se le asigne, por ejemplo, vemos el siguiente código:</span></span></p>
<p style="margin-bottom:0;font-weight:normal;text-align:justify;">
<pre style="margin-bottom:0;text-align:left;"><span style="color:#c0c0c0;"><span style="font-family:Monospace;"><span style="font-size:x-small;"><span style="font-style:normal;">#!/usr/bin/env python</span></span></span></span><span style="font-family:Monospace;"><span style="font-size:x-small;"><span style="color:#000000;">
a </span><span style="color:#000000;">= </span><span style="color:#800000;">5</span><span style="color:#c0c0c0;"> # "a" guarda un valor entero</span><span style="color:#0000ff;">
print </span><span style="color:#000000;">a, </span><span style="color:#000000;">type(a)
a</span><span style="color:#000000;"> = </span><span style="color:#00aa00;"><em>"hola" </em></span><span style="color:#c0c0c0;"># ahora "a" guarda una cadena</span><span style="color:#0000ff;">
print</span><span style="color:#000000;"> a, </span><span style="color:#000000;">type(a)
a</span><span style="color:#000000;"> = </span><span style="color:#800000;">5.4</span><span style="color:#c0c0c0;"> # ahora "a" guarda un valor float</span><span style="color:#0000ff;">
print </span><span style="color:#000000;">a,</span><span style="color:#000000;"> type(a)
a</span><span style="color:#000000;"> = </span><span style="color:#000000;">(</span><span style="color:#800000;">4</span><span style="color:#000000;">+</span><span style="color:#800000;">2</span><span style="color:#000000;">j)</span><span style="color:#c0c0c0;"> # ahora "a" guarda un valor del tipo complejo</span></span><span style="color:#0000ff;"><span style="font-size:x-small;">
print</span></span><span style="color:#000000;"><span style="font-size:x-small;"> a, </span></span><span style="color:#000000;"><span style="font-size:x-small;">type(a)</span></span></span></pre>
<p style="margin-bottom:0;font-weight:normal;text-align:justify;">
<p style="margin-bottom:0;font-weight:normal;text-align:justify;"><span style="font-family:FreeSans,sans-serif;"><span style="font-style:normal;">Un ejemplo gráfico para que sea más entendible <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' />  :</span></span></p>
<p style="margin-bottom:0;font-weight:normal;text-align:justify;"><img style="border:0 none;text-align:left;" src="http://pycj.files.wordpress.com/2009/11/sbres_1258260263_0__.png?w=64&#038;h=41" border="0" alt="" width="64" height="41" /></p>
<p style="margin-bottom:0;font-weight:normal;text-align:justify;"><span style="font-family:FreeSans,sans-serif;"><span style="font-style:normal;">a = 5</span></span></p>
<p>asignamos el valor entero “5” a la variable “a”</p>
<p style="margin-bottom:0;font-weight:normal;text-align:justify;">
<p style="margin-bottom:0;font-weight:normal;text-align:justify;"><img style="border:0 none;text-align:left;" src="http://pycj.files.wordpress.com/2009/11/sbres_1258260263_1__.png?w=199&#038;h=60" border="0" alt="" width="199" height="60" /></p>
<p style="margin-bottom:0;font-weight:normal;text-align:justify;"><span style="font-family:FreeSans,sans-serif;"><span style="font-style:normal;">a = “hola”</span></span></p>
<p>asignamos la cadena “hola” a la variable “a”, que antes apuntaba a un valor entero, el cual al quedar libre es borrado de la memoria.</p>
<p style="margin-bottom:0;font-weight:normal;text-align:justify;"><span style="font-family:FreeSans,sans-serif;"><span style="font-style:normal;">Como la variable “a” no fue “ declarada” para ser de ningún tipo, osea que no se declaro explícitamente que “a” sea de tipo entero o cadena o real o algún otro tipo, puede guardar el valor que se le asigne, pero eso sí, es un lenguaje fuertemente tipado, es decir que no podemos mezclar diferentes tipos de variables.</span></span></p>
<p style="margin-bottom:0;font-weight:normal;text-align:justify;"><span id="more-87"></span></p>
<p style="margin-bottom:0;font-weight:normal;text-align:justify;">
<h2 style="margin-bottom:0;text-align:justify;"><span style="font-family:FreeSans,sans-serif;"><span style="text-decoration:underline;"><strong><span style="font-style:normal;">Fuertemente Tipado</span></strong></span></span></h2>
<p style="margin-bottom:0;text-align:justify;"><span style="font-family:FreeSans,sans-serif;"><span style="font-style:normal;"><span style="text-decoration:none;"><span style="font-weight:normal;">La característica de «Fuertemente Tipado» se refiere a que una vez que una variable guarda un valor, no se puede tratar a dicho valor como si fuera de otro tipo, es decir no se pueden realizar operaciones entre variables o valores de diferentes tipos, ejemplo: si tenemos una variable que guarda el numero entero 9, no podemos sumarle un valor del tipo cadena como “ 5”, pero en otros lenguajes si es posible ya que las variables cambiarían para adaptarse a la operación deseada, pero esto es más propenso a errores en una programación más extensa, si queremos tener ese comportamiento con nuestras variables en Python, es necesario</span></span></span><strong><em><span style="text-decoration:none;">«mutarlas»</span></em></strong><span style="font-style:normal;"><span style="text-decoration:none;"><span style="font-weight:normal;">explícitamente, ejemplo en código:</span></span></span></span></p>
<pre style="margin-bottom:0;text-align:left;"><span style="color:#c0c0c0;"><span style="font-family:Monospace;"><span style="font-size:x-small;">#!/usr/bin/env python</span></span></span><span style="font-family:Monospace;"><span style="font-size:x-small;"><span style="color:#000000;"><span style="font-style:normal;"><span style="text-decoration:none;"><span style="font-weight:normal;">
a </span></span></span></span><span style="color:#000000;"><span style="font-style:normal;"><span style="text-decoration:none;"><span style="font-weight:normal;">= </span></span></span></span><span style="color:#800000;"><span style="font-style:normal;"><span style="text-decoration:none;"><span style="font-weight:normal;">9 </span></span></span></span><span style="color:#c0c0c0;"><span style="font-style:normal;"><span style="text-decoration:none;"><span style="font-weight:normal;"># valor entero</span></span></span></span><span style="color:#000000;">
b </span><span style="color:#000000;">= </span><span style="color:#00aa00;"><em>"5" </em></span><span style="color:#c0c0c0;"># valor entero</span></span><span style="color:#000000;"><span style="font-size:x-small;">
c </span></span><span style="color:#000000;"><span style="font-size:x-small;">= </span></span><span style="color:#000000;"><span style="font-size:x-small;">a </span></span><span style="color:#000000;"><span style="font-size:x-small;">+ </span></span><span style="color:#000000;"><span style="font-size:x-small;">b </span></span><span style="color:#c0c0c0;"><span style="font-size:x-small;"># no se puede realizar esta operacion</span></span><span style="font-size:x-small;"><span style="color:#0000ff;">
print</span><span style="color:#323232;"> c</span></span></span></pre>
<p style="margin-bottom:0;font-weight:normal;text-align:justify;"><span style="font-family:FreeSans,sans-serif;">al detectar esto, Python mostrará un mensaje como este:</span></p>
<blockquote>
<p style="margin-bottom:0;text-align:left;"><span style="font-family:Monospace;"><span style="font-size:x-small;"><span style="color:#ff0000;"><span style="font-weight:normal;">Traceback (most recent call last):</span></span></span></span><span style="color:#ff0000;"><span style="font-family:Monospace;"><span style="font-size:x-small;"><span style="font-weight:normal;"><br />
File &#8220;var3ejem2.py&#8221;, line 4, in &lt;module&gt;</span><br />
c = a + b # no se puede realizar esta operacion</span></span></span><span style="font-family:Monospace;"><span style="color:#ff0000;"><span style="font-size:x-small;"><br />
TypeError: unsupported operand type(s) for +: &#8216;int&#8217; and &#8216;str&#8217;</span></span></span></p>
</blockquote>
<p style="margin-bottom:0;font-weight:normal;text-align:justify;"><span style="font-family:FreeSans,sans-serif;">es decir que la operación “+” no está soportada para actuar con variables del tipo  <em>int</em> y  <em>str</em> (entero y cadena)</span></p>
<p style="margin-bottom:0;font-weight:normal;text-align:justify;">
<h3 style="margin-bottom:0;font-style:normal;text-align:justify;"><span style="font-family:FreeSans,sans-serif;"><span style="text-decoration:underline;"><strong>Mutación de variables</strong></span></span></h3>
<p style="margin-bottom:0;font-weight:normal;text-align:justify;"><span style="font-family:FreeSans,sans-serif;">Si queremos sumar los valores de dos cadenas o un número con una cadena, ejemplo “5” + “9” o 5 + “9” debemos de convertir la cadena al tipo del número, ya sea entero o real o cualquier otro tipo numérico. Para eso se utilizan las funciones que Python trae, ejemplo:</span></p>
<pre style="margin-bottom:0;text-align:left;"><span style="color:#c0c0c0;"><span style="font-family:Monospace;"><span style="font-size:x-small;">#!/usr/bin/env python</span></span></span><span style="font-family:Monospace;"><span style="font-size:x-small;"><span style="color:#000000;">
a </span><span style="color:#000000;">= </span><span style="color:#800000;">5 </span><span style="color:#c0c0c0;"># la variable "a" guarda un valor entero</span><span style="color:#000000;">
b</span><span style="color:#000000;"> = </span><span style="color:#00aa00;"><em>"9" </em></span><span style="color:#c0c0c0;"># la variable "b" guarda una cadena</span><span style="color:#000000;">
c</span><span style="color:#000000;"> = </span><span style="color:#000000;">a </span><span style="color:#000000;">+ </span><span style="color:#000000;">int(b) </span><span style="color:#c0c0c0;"># con la funcion int() convertimos
               # la cadena un entero</span></span><span style="color:#0000ff;"><span style="font-size:x-small;">
print</span></span><span style="color:#000000;"><span style="font-size:x-small;"> c</span></span></span></pre>
<p style="margin-bottom:0;font-weight:normal;text-align:justify;"><span style="font-family:FreeSans,sans-serif;">y así podemos mutar las variables para que se comporten de la manera que queremos, pero ojo, que luego “b” sigue siendo una cadena, si queremos que sea un entero para el resto del código, simplemente la reasignamos con el nuevo valor.</span></p>
<pre style="margin-bottom:0;font-weight:normal;text-align:justify;"><span style="font-family:Monospace;"><span style="font-size:x-small;"><span style="color:#000000;">b </span><span style="color:#000000;">= </span><span style="color:#000000;">int(b)</span></span></span></pre>
<p style="margin-bottom:0;font-weight:normal;text-align:justify;">
</div>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/pycj.wordpress.com/87/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/pycj.wordpress.com/87/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/pycj.wordpress.com/87/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/pycj.wordpress.com/87/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/pycj.wordpress.com/87/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/pycj.wordpress.com/87/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/pycj.wordpress.com/87/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/pycj.wordpress.com/87/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/pycj.wordpress.com/87/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/pycj.wordpress.com/87/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/pycj.wordpress.com/87/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/pycj.wordpress.com/87/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/pycj.wordpress.com/87/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/pycj.wordpress.com/87/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=pycj.wordpress.com&amp;blog=8684468&amp;post=87&amp;subd=pycj&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://pycj.wordpress.com/2009/11/14/variables-parte-3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/d0fa25be2c38f9394f97011524c5c387?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">carlosj2585</media:title>
		</media:content>

		<media:content url="http://pycj.files.wordpress.com/2009/11/sbres_1258260263_0__.png" medium="image" />

		<media:content url="http://pycj.files.wordpress.com/2009/11/sbres_1258260263_1__.png" medium="image" />
	</item>
		<item>
		<title>Variables &#8211; Parte 2</title>
		<link>http://pycj.wordpress.com/2009/11/10/variables-parte-2/</link>
		<comments>http://pycj.wordpress.com/2009/11/10/variables-parte-2/#comments</comments>
		<pubDate>Tue, 10 Nov 2009 14:18:24 +0000</pubDate>
		<dc:creator>Carlos Joel</dc:creator>
				<category><![CDATA[Variables]]></category>

		<guid isPermaLink="false">http://pycj.wordpress.com/2009/11/10/variables-parte-2/</guid>
		<description><![CDATA[  Ya vimos los tipos básicos de datos en Python, los cuales hemos llamado «variables», pero en realidad ese no es el nombre correcto en Python, lo correcto es « nombres» o «etiquetas»; pero, para no salir de la terminología común, la cual es entendida por todo el mundo, vamos a seguir llamándolos «variables», pero [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=pycj.wordpress.com&amp;blog=8684468&amp;post=75&amp;subd=pycj&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<div>
<p style="margin-bottom:0;font-weight:normal;text-align:justify;"> </p>
<p><span style="font-family:FreeSans,sans-serif;">Ya vimos los tipos básicos de datos en Python, los cuales hemos llamado  <strong>«variables»</strong>, pero en realidad ese no es el nombre correcto en Python, lo correcto es « <strong>nombres»</strong> o  <strong>«etiquetas»</strong>; pero, para no salir de la terminología común, la cual es entendida por todo el mundo, vamos a seguir llamándolos «variables», pero debemos tener en cuenta:</span></p>
<p style="margin-bottom:0;font-weight:normal;text-align:justify;"><span style="font-family:FreeSans,sans-serif;">Los otros lenguajes (la mayoría) tienen «variables», a las que se les asigna valores, por ejemplo:</span></p>
<blockquote><p style="margin-bottom:0;font-weight:normal;text-align:justify;"><span style="font-family:FreeSans,sans-serif;">Declaración de variables en Java o C#:<span style="color:#0000ff;"> </span></span></p>
<p> <span style="margin-bottom:0;text-align:justify;padding-left:30px;"><span style="font-family:FreeSans,sans-serif;"><span style="color:#0000ff;">int</span> a = 5;</span></span></p>
<p> <span style="margin-bottom:0;font-weight:normal;text-align:justify;"><span style="font-family:FreeSans,sans-serif;">Declaración de variables en Basic: </span></span></p>
<p> <span style="margin-bottom:0;font-weight:normal;text-align:justify;padding-left:30px;"><span style="font-family:FreeSans,sans-serif;"><span style="color:#0000ff;">Dim</span> a  <span style="color:#0000ff;">as Integer</span><span style="color:#000000;">= 5</span></span></span></p>
</blockquote>
<p style="margin-bottom:0;font-weight:normal;text-align:justify;"><span style="color:#000000;"><span style="font-family:FreeSans,sans-serif;">y así cada lenguaje tiene su manera de declarar variables&#8230;</span></span></p>
<p style="margin-bottom:0;font-weight:normal;text-align:justify;"> </p>
<p style="margin-bottom:0;font-weight:normal;text-align:justify;"><em><span style="font-family:FreeSans,sans-serif;">¿Qué quiere decir esto?</span></em></p>
<p style="margin-bottom:0;font-weight:normal;text-align:justify;"><span style="font-family:FreeSans,sans-serif;"><span id="more-75"></span>Que al momento de declarar una variable, se crea un espacio en la memoria que se comporta como una caja, en donde se almacenan los valores asignados.</span></p>
<p style="margin-bottom:0;font-weight:normal;text-align:justify;"> </p>
<p style="margin-bottom:0;font-weight:normal;text-align:justify;"><span style="font-family:FreeSans,sans-serif;">Al  <span style="text-decoration:none;">declarar</span> la variable “a” se tiene:</span></p>
<blockquote><p style="margin-bottom:0;font-weight:normal;text-align:justify;"><span style="font-family:FreeSans,sans-serif;"><span style="color:#0000ff;">int</span> a = 5; </span></p>
<p style="margin-bottom:0;font-weight:normal;text-align:justify;"><span style="font-family:FreeSans,sans-serif;"> </span><img style="border:0 none;text-align:left;" src="http://pycj.files.wordpress.com/2009/11/sbres_1257862689_0__.png?w=46&#038;h=56" border="0" alt="" width="46" height="56" /></p>
</blockquote>
<p style="margin-bottom:0;font-weight:normal;text-decoration:none;text-align:justify;"> </p>
<p style="margin-bottom:0;font-weight:normal;text-decoration:none;text-align:justify;"> </p>
<p style="margin-bottom:0;font-weight:normal;text-decoration:none;text-align:justify;"><span style="font-family:FreeSans,sans-serif;">Si le asignamos otro valor a la variable “a”, el valor anterior es sobrescrito, por ejemplo</span></p>
<blockquote><p style="margin-bottom:0;font-weight:normal;text-decoration:none;text-align:justify;">a = 8;</p>
<p style="margin-bottom:0;font-weight:normal;text-decoration:none;text-align:justify;"><img style="border:0 none;text-align:left;" src="http://pycj.files.wordpress.com/2009/11/sbres_1257862689_1__.png?w=46&#038;h=56" border="0" alt="" width="46" height="56" /></p>
</blockquote>
<p style="margin-bottom:0;font-weight:normal;text-decoration:none;text-align:justify;"><span style="font-family:FreeSans,sans-serif;"> </span></p>
<p style="margin-bottom:0;font-weight:normal;text-decoration:none;text-align:justify;"> </p>
<p style="margin-bottom:0;font-weight:normal;text-decoration:none;text-align:justify;"><span style="font-family:FreeSans,sans-serif;">Si declaramos otra variable “b”, y le asignamos el valor de “a”, esto crea una copia del contenido de “a” en “b”.</span></p>
<blockquote><p style="margin-bottom:0;font-weight:normal;text-decoration:none;text-align:justify;"><span style="color:#0000ff;">int</span> b = a;</p>
<p style="margin-bottom:0;font-weight:normal;text-decoration:none;text-align:justify;"><img style="border:0 none;text-align:left;" src="http://pycj.files.wordpress.com/2009/11/sbres_1257862689_2__.png?w=46&#038;h=56" border="0" alt="" width="46" height="56" /> <img style="border:0 none;text-align:left;" src="http://pycj.files.wordpress.com/2009/11/sbres_1257862689_3__.png?w=46&#038;h=56" border="0" alt="" width="46" height="56" /></p>
</blockquote>
<p style="margin-bottom:0;font-weight:normal;text-decoration:none;text-align:justify;"><span style="font-family:FreeSans,sans-serif;">Luego, el valor de “b” es independiente al valor de “a”.</span></p>
<p style="margin-bottom:0;text-decoration:none;text-align:justify;"> </p>
<p style="margin-bottom:0;text-decoration:none;text-align:justify;"><span style="font-family:FreeSans,sans-serif;"><strong>En Python se usan “nombres” o “etiquetas”</strong></span></p>
<p style="margin-bottom:0;font-weight:normal;text-decoration:none;text-align:justify;"> </p>
<p style="margin-bottom:0;font-weight:normal;text-decoration:none;text-align:justify;"><span style="font-family:FreeSans,sans-serif;">Como en Python  <span style="color:#00ae00;"><em><strong>«todo es un objeto»</strong></em></span>, este comportamiento es algo diferente, Python tiene «nombres» o «etiquetas».</span></p>
<p style="margin-bottom:0;font-weight:normal;text-decoration:none;text-align:justify;"><span style="font-family:FreeSans,sans-serif;">Al hacer:</span></p>
<blockquote><p style="margin-bottom:0;font-weight:normal;text-decoration:none;text-align:justify;"><span style="font-family:FreeSans,sans-serif;">a = 5, estamos etiquetando al  <strong>objeto entero</strong> “5” con “a”</span></p>
<p style="margin-bottom:0;font-weight:normal;text-decoration:none;text-align:justify;"><img style="border:0 none;text-align:left;" src="http://pycj.files.wordpress.com/2009/11/sbres_1257862689_4__.png?w=64&#038;h=41" border="0" alt="" width="64" height="41" /></p>
</blockquote>
<p style="margin-bottom:0;font-weight:normal;text-decoration:none;text-align:justify;"> </p>
<p style="margin-bottom:0;font-weight:normal;text-decoration:none;text-align:justify;"><span style="font-family:FreeSans,sans-serif;">Si asignamos un nuevo valor a “a”,  por ejemplo:</span></p>
<blockquote><p style="margin-bottom:0;font-weight:normal;text-decoration:none;text-align:justify;"><span style="font-family:FreeSans,sans-serif;">a = 8, estamos colocando la etiqueta “a” a un nuevo objeto.</span></p>
<p style="margin-bottom:0;font-weight:normal;text-decoration:none;text-align:justify;"><img style="border:0 none;text-align:left;" src="http://pycj.files.wordpress.com/2009/11/sbres_1257862689_5__.png?w=94&#038;h=42" border="0" alt="" width="94" height="42" /></p>
</blockquote>
<p style="margin-bottom:0;font-weight:normal;text-decoration:none;text-align:justify;"><span style="font-family:FreeSans,sans-serif;">Y el objeto 5 queda libre, puede seguir existiendo en la memoria, pero como nadie hace referencia a él, es borrado.</span></p>
<p style="margin-bottom:0;font-weight:normal;text-decoration:none;text-align:justify;"><span style="font-family:FreeSans,sans-serif;">Si creamos una nueva etiqueta “b” y le asignamos el valor de “a”, osea:</span></p>
<blockquote><p style="margin-bottom:0;font-weight:normal;text-decoration:none;text-align:justify;"><span style="font-family:FreeSans,sans-serif;">b = a, estamos agregando otra etiqueta al mismo objeto al que “a” hace referencia.</span></p>
<p style="margin-bottom:0;font-weight:normal;text-decoration:none;text-align:justify;"><img style="border:0 none;text-align:left;" src="http://pycj.files.wordpress.com/2009/11/sbres_1257862689_6__.png?w=96&#038;h=42" border="0" alt="" width="96" height="42" /></p>
</blockquote>
<p style="margin-bottom:0;font-weight:normal;text-align:justify;"> </p>
<p style="margin-bottom:0;font-weight:normal;text-align:justify;"><span style="font-family:FreeSans,sans-serif;">Esto significa eficiencia en el uso de memoria, pero si cambiamos el valor de “a”, por ejemplo hacemos una operación aritmética, como restarle 1</span></p>
<blockquote><p style="margin-bottom:0;font-weight:normal;text-align:justify;"><span style="font-family:FreeSans,sans-serif;">a = a – 1</span></p>
</blockquote>
<p style="margin-bottom:0;font-weight:normal;text-align:justify;"><span style="font-family:FreeSans,sans-serif;">al hacer esto se está creando un nuevo objeto y se etiqueta con “a”, entonces tendremos dos objetos diferentes con etiquetas independientes.</span></p>
<blockquote><p style="margin-bottom:0;font-weight:normal;text-align:justify;"><img style="border:0 none;text-align:left;" src="http://pycj.files.wordpress.com/2009/11/sbres_1257862689_7__.png?w=138&#038;h=42" border="0" alt="" width="138" height="42" /></p>
</blockquote>
<p style="margin-bottom:0;font-weight:normal;text-align:justify;"> </p>
<p style="margin-bottom:0;font-weight:normal;text-align:justify;"><span style="font-family:FreeSans,sans-serif;">Espero que no haya dudas sobre como Python maneja las “etiquetas”, pero para evitarnos complicaciones más adelante, sigamos llamándolas  <strong>«variables»</strong> <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> .</span></p>
<p style="margin-bottom:0;font-weight:normal;text-align:justify;"><span style="font-family:FreeSans,sans-serif;">Dale una revisada al siguiente código:</span></p>
<p><code>a = 5 # se etiqueta el objeto entero 5 con "a"</p>
<p> print a # muestra el objeto de "a"</p>
<p> a = 8 # se etiqueta otro objeto con "a"</p>
<p> b = a # se agrega la etiqueta "b" al objeto de "a"</p>
<p> print b # se muestra el objeto de "b"</p>
<p> a = a – 1 # se modifica el valor del objeto de "a"</p>
<p> print a # se muestra el objeto de "a"</p>
<p> print b # se muestra el objeto de "b", que ahora es independiente</code></p>
<p style="margin-bottom:0;font-weight:normal;text-align:justify;"><span style="font-family:FreeSans,sans-serif;">El mismo código con una «traducción más común» de los comentarios:</span></p>
<p><code>a = 5 # se crea la variable entera "a" y se guarda el valor "5"</p>
<p> print a # muestra el valor de "a"</p>
<p> a = 8 # se guarda un nuevo valor en "a"</p>
<p> b = a # se crea la variable "b" donde guarda el valor de "a"</p>
<p> print b # se muestra el valor de "b"</p>
<p> a = a – 1 # se modifica el valor de "a"</p>
<p> print a # se muestra el valor de "a"</p>
<p> print b # se muestra el valor de "b"</code></p>
</div>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/pycj.wordpress.com/75/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/pycj.wordpress.com/75/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/pycj.wordpress.com/75/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/pycj.wordpress.com/75/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/pycj.wordpress.com/75/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/pycj.wordpress.com/75/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/pycj.wordpress.com/75/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/pycj.wordpress.com/75/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/pycj.wordpress.com/75/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/pycj.wordpress.com/75/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/pycj.wordpress.com/75/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/pycj.wordpress.com/75/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/pycj.wordpress.com/75/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/pycj.wordpress.com/75/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=pycj.wordpress.com&amp;blog=8684468&amp;post=75&amp;subd=pycj&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://pycj.wordpress.com/2009/11/10/variables-parte-2/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/d0fa25be2c38f9394f97011524c5c387?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">carlosj2585</media:title>
		</media:content>

		<media:content url="http://pycj.files.wordpress.com/2009/11/sbres_1257862689_0__.png" medium="image" />

		<media:content url="http://pycj.files.wordpress.com/2009/11/sbres_1257862689_1__.png" medium="image" />

		<media:content url="http://pycj.files.wordpress.com/2009/11/sbres_1257862689_2__.png" medium="image" />

		<media:content url="http://pycj.files.wordpress.com/2009/11/sbres_1257862689_3__.png" medium="image" />

		<media:content url="http://pycj.files.wordpress.com/2009/11/sbres_1257862689_4__.png" medium="image" />

		<media:content url="http://pycj.files.wordpress.com/2009/11/sbres_1257862689_5__.png" medium="image" />

		<media:content url="http://pycj.files.wordpress.com/2009/11/sbres_1257862689_6__.png" medium="image" />

		<media:content url="http://pycj.files.wordpress.com/2009/11/sbres_1257862689_7__.png" medium="image" />
	</item>
		<item>
		<title>Variables en Python</title>
		<link>http://pycj.wordpress.com/2009/11/03/variables-en-python/</link>
		<comments>http://pycj.wordpress.com/2009/11/03/variables-en-python/#comments</comments>
		<pubDate>Tue, 03 Nov 2009 20:47:57 +0000</pubDate>
		<dc:creator>Carlos Joel</dc:creator>
				<category><![CDATA[Codigos]]></category>
		<category><![CDATA[Variables]]></category>
		<category><![CDATA[Bool]]></category>
		<category><![CDATA[Cadenas]]></category>
		<category><![CDATA[Números]]></category>
		<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://pycj.wordpress.com/?p=48</guid>
		<description><![CDATA[En Python los tipos básicos para las variables se dividen en: Números: enteros (123), reales o coma flotante (-43.23) y complejos (4 + 3j), en Python la parte imaginaria de un número complejo se representa con j y no con i como es matemáticamente. Cadenas de texto: &#8220;Hola&#8221;, &#8220;abc123&#8243;. Valores booleanos: True (cierto) y False [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=pycj.wordpress.com&amp;blog=8684468&amp;post=48&amp;subd=pycj&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>En Python los tipos básicos para las variables se dividen en:</p>
<ul>
<li>Números: enteros (123), reales o coma flotante (-43.23) y complejos (4 + 3j), en Python la parte imaginaria de un número complejo se representa con <em>j</em> y no con <em>i</em> como es matemáticamente.</li>
<li>Cadenas de texto: &#8220;Hola&#8221;, &#8220;abc123&#8243;.</li>
<li>Valores booleanos: True (cierto) y False (falso).</li>
</ul>
<p>Vamos a crear un par de variables a modo de ejemplo. Una de tipo cadena y una de tipo entero:</p>
<p><code># en la variable cadena guardamos una cadena<br />
cadena = "Hola"<br />
# y en entero un número entero<br />
entero = 23<br />
# lo comprobamos con la función type<br />
print type(cadena)<br />
print type(entero)</code></p>
<p>El resultado será:</p>
<blockquote><p>&lt;type &#8216;str&#8217;&gt;<br />
&lt;type &#8216;int&#8217;&gt;</p></blockquote>
<p>Lo que indica que la variable cadena es del tipo <em>str</em>, que es lo mismo que string o cadena, y la variable entero es del tipo <em>int</em>, que significa integer o entero.</p>
<p>Además vemos que los comentarios en Python se indican con el signo #, pero existen más formas de insertar comentarios, lo que veremos más adelante.</p>
<p><strong><span id="more-48"></span>Enteros</strong></p>
<p>En Python los enteros son <em>int</em> (tipo integer o entero) o <em>long</em> (tipo de entero largo).</p>
<p>En Python, utilizando el tipo <em>int</em> podemos almacenar números de -2<sup>31</sup> a 2<sup>31</sup> &#8211; 1, o lo que es lo mismo, de -2.147.483.648 a 2.147.483.647, eso en plataformas de 32bits. En plataformas de 64 bits, el rango es de -9.223.372.036.854.775.808 hasta 9.223.372.036.854.775.807 Para declarar un tipo entero o <em>int</em> es suficiente asignar un número entero a una variable, ejemplo:</p>
<p><code>entero = 23</code></p>
<p>Para declarar un tipo entero largo o <em>long</em> hay que añadir la letra L al final del número</p>
<p><code>entero = 23L</code></p>
<p>También se puede expresar la variable como un octal, anteponiendo un cero:</p>
<p><code># 027 octal = 23 en base 10<br />
entero = 027</code></p>
<p>o bien en hexadecimal, anteponiendo un 0x:</p>
<p><code># 0×17 hexadecimal = 23 en base 10<br />
entero = 0×17</code></p>
<p><strong>Reales</strong></p>
<p>Son los números que tienen decimales, en Python se representan con el tipo <em>float, </em>Python siempre se utiliza este tipo de variables con doble precisión (tipo <em>double</em> en lenguaje C), y en concreto se sigue el estándar IEEE 754: 1 bit para el signo, 11 para el exponente, y 52 para la mantisa. Esto significa que los valores que podemos representar van desde ±2,2250738585072020&#215;10<sup>-308</sup> hasta ±1,7976931348623157×10<sup>308, </sup>para asignar este tipo de números se escribe la parte entera y luego la parte decimal, ejemplo:</p>
<p><code>real = 25.85<br />
real = 19.00</code></p>
<p>También es posible utilizar la notación científica, por ejemplo:</p>
<p><code>real = 19.886e-7</code></p>
<p>Lo que sería igual a decir: 0.0000019886</p>
<p><strong>Complejos</strong></p>
<p>Son los números que tienen parte imaginaria, en Python este tipo es conocido como complex, y se asigna a una variable de la siguiente manera:</p>
<p><code>complejo = 4.2 + 2.5j</code></p>
<p>Nótese <span style="text-decoration:line-through;">nuevamente</span> que la parte imaginaria se representa con la letra <em>j</em>.</p>
<p><strong>Cadenas</strong></p>
<p>Es el conjunto de letras o números encerrados entre comillas dobles (&#8220;texto&#8221;) o comillas simples (&#8216;texto&#8217;) las cuales pueden contener caracteres especiales como \n para saltar a una línea nueva o \t para agregar un espacio de tabulación.</p>
<p><code>texto = "Hola mundo" # El resultado se mostrará en una sola linea<br />
texto = "Hola<strong>\n</strong>mundo" # El resultado se mostrará en dos lineas distintas<br />
</code></p>
<p>También se puede poner texto entre triples comillas, lo cual, al momento de presentarlo o escribirlo en la consola, respetará los saltos de línea sin necesidad de utilizar \n</p>
<p><code>triple = """Esta es una línea<br />
y esta es otra línea"""</code></p>
<p>Las cadenas admiten las operaciones + y * para concatenación, ejemplo</p>
<p><code>a = “uno”<br />
b = “dos”<br />
c = a * 3<br />
print a + b<br />
print c</code></p>
<p>el resultado será</p>
<blockquote><p>unodos<br />
unounouno</p></blockquote>
<p><strong>Booleanos</strong></p>
<p>Las variables de tipo <em>bool </em>en Python (y todos los otros lenguajes) almacenan dos valores: True y False, solo que en Python el tipo bool es una subclase del tipo int, es decir que True vale 1 y False vale 0, algo curioso, ya que si haces:</p>
<p><code>a = True + True</code></p>
<p>El resultado será 2</p>
<p>Prueba con lo siguiente y fíjate en el resultado.</p>
<p><code>a = True + True<br />
b = True<br />
print a<br />
print type(a)<br />
print b<br />
print type(b)</code></p>
<p>Vemos que el valor de a es 2 y su tipo es int, y el valor de b es True y su tipo es <em>bool</em>, esto se debe, como ya dije, a que el tipo bool es una subclase del tipo <em>int</em>.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/pycj.wordpress.com/48/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/pycj.wordpress.com/48/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/pycj.wordpress.com/48/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/pycj.wordpress.com/48/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/pycj.wordpress.com/48/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/pycj.wordpress.com/48/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/pycj.wordpress.com/48/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/pycj.wordpress.com/48/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/pycj.wordpress.com/48/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/pycj.wordpress.com/48/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/pycj.wordpress.com/48/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/pycj.wordpress.com/48/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/pycj.wordpress.com/48/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/pycj.wordpress.com/48/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=pycj.wordpress.com&amp;blog=8684468&amp;post=48&amp;subd=pycj&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://pycj.wordpress.com/2009/11/03/variables-en-python/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/d0fa25be2c38f9394f97011524c5c387?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">carlosj2585</media:title>
		</media:content>
	</item>
		<item>
		<title>Primer encuentro con Python</title>
		<link>http://pycj.wordpress.com/2009/10/31/primer-encuentro-con-python/</link>
		<comments>http://pycj.wordpress.com/2009/10/31/primer-encuentro-con-python/#comments</comments>
		<pubDate>Sun, 01 Nov 2009 02:16:10 +0000</pubDate>
		<dc:creator>Carlos Joel</dc:creator>
				<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://pycj.wordpress.com/?p=37</guid>
		<description><![CDATA[Primer encuentro con Python Si eres de los que todavía utilizan Windows®, debes instalar el interprete de Python, el cual puedes obtenerlo desde la página oficial de Python http://www.python.org. Si utilizas GNU/Linux lo más probable (casi seguro) es que Python ya esté instalado, y si no lo está, puedes instalarlo fácilmente utilizando el gestor de [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=pycj.wordpress.com&amp;blog=8684468&amp;post=37&amp;subd=pycj&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><strong><span style="text-decoration:underline;">Primer encuentro con Python</span></strong></p>
<p>Si eres de los que todavía utilizan Windows®, debes instalar el interprete de Python, el cual puedes obtenerlo desde la página oficial de Python <a href="http://www.python.org/">http://www.python.org</a>.</p>
<p>Si utilizas GNU/Linux lo más probable (casi seguro) es que Python ya esté instalado, y si no lo está, puedes instalarlo fácilmente utilizando el gestor de paquetes de tu distribución, o también bajándolo desde la página oficial de Python; en otros sistemas operativos Unix y compatibles (MacOSX, oSolaris, etc.) Python también puede encontrarse ya instalado, y también puede ser instalado fácilmente.</p>
<p>Para empezar a programar es suficiente un editor de texto sencillo, guardar nuestro código con la extensión .py y luego ejecutarlo con el interprete.</p>
<p>El instalador para Windows® viene con IDLE, un entorno de desarrollo para Python.</p>
<p>Tanto para Windows®, GNU/Linux y demás sistemas Unix podemos instalar PyDEV que es uno de los mejores IDEs (entornos de desarrollo) para Python, bueno, en realidad PyDEV es un complemento (plugin) que puede ser instalado en Eclipse o Aptana, por lo que primero debemos instalar Eclipse o Aptana y luego instalar PyDEV, o podemos utilizar EasyEclipse para Python, que es una modificación de Eclipse y que además tiene una distribución que ya viene con PyDEV instalado. PyDEV cuenta con autocompletado de código (con información sobre cada elemento), resaltado de sintaxis, un depurador gráfico, resaltado de errores, explorador de clases, formateo del código, refactorización, etc.</p>
<p>EasyEclipse se puede descargar desde <a href="http://www.easyeclipse.org/site/distributions/python.html">http://www.easyeclipse.org/site/distributions/python.html</a></p>
<p><span id="more-37"></span>En GNU/Linux para asegurarse que tiene Python instalado abra una terminal y escriba el comando python, el cual llama al intérprete, debería ver lo siguiente:</p>
<blockquote><p>~$ python</p>
<p>Python 2.6.4rc2 (r264rc2:75497, Oct 20 2009, 02:54:09)</p>
<p>[GCC 4.4.1] on linux2</p>
<p>Type &#8220;help&#8221;, &#8220;copyright&#8221;, &#8220;credits&#8221; or &#8220;license&#8221; for more information.</p>
<p>&gt;&gt;&gt;</p></blockquote>
<p>Los 3 signos <strong>&gt;&gt;&gt;</strong> indican que el interprete está activo y esperando ordenes. Para salir del interprete solo se debe escribir exit() o presionar las teclas Ctrl+D.</p>
<p>Prueba escribiendo:</p>
<p><code>print "Hola mundo, este es mi primer programa en Python"</code></p>
<p>También puedes crear un documento de texto nuevo o utilizar Pydev y escribir la misma línea de código, luego guardar el archivo como Hola.py y ejecutarlo con el intérprete</p>
<blockquote><p>~$ python hola.py</p></blockquote>
<p>y acabas de hacer tu primer programa en python.</p>
<p>Si utilizas Windows® los archivos .py ya estarán asociados al intérprete de Python, por lo que basta hacer doble clic sobre el archivo para ejecutar el programa. Sin embargo como este programa no hace más que imprimir un texto en la consola, la ejecución es demasiado rápida para poder verlo. Para remediarlo, vamos a añadir una nueva línea que espere la entrada de datos por parte del usuario.</p>
<p><code>print "Hola mundo, este es mi primer programa en Python"</p>
<p>raw_input()</code></p>
<p>De esta forma se mostrará una consola con el texto hasta que se presione la tecla Enter.</p>
<p>Si utilizas Linux (u otro Unix) para conseguir este comportamiento, es decir, para que el sistema operativo abra el archivo .py con el intérprete adecuado, es necesario añadir una nueva línea al principio del archivo:</p>
<p><code>#!/usr/bin/env python</p>
<p>print "Hola mundo, este es mi primer programa en Python"</p>
<p>raw_input()</code></p>
<p>A esta línea se le conoce en el mundo Unix como <em>shebang, hashbang </em>o<em> sharpbang</em>. El par de caracteres #! indica al sistema operativo que dicho script se debe ejecutar utilizando el intérprete especificado a continuación. De esto se desprende, evidentemente, que si esta no es la ruta en la que está instalado nuestro intérprete de Python, es necesario cambiarla.</p>
<p>Por supuesto además de añadir el shebang, tendremos que dar permisos de ejecución al programa.</p>
<blockquote><p>chmod +x hola.py</p></blockquote>
<p>Y listo, si hacemos doble clic el programa se ejecutará, mostrando una consola con el texto <em>Hola mundo, este es mi primer programa en Python</em>, como en el caso de Windows®.</p>
<p>También podríamos correr el programa desde la consola como si tratara de un ejecutable cualquiera:</p>
<blockquote><p>./hola.py</p></blockquote>
<p>Ahora, si queremos insertar texto con caracteres especiales, es decir, tildes, eñe «ñ» y otros simbolos, debemos agregar la siguiente linea a nuestro programa, justo debajo del sharpbang:</p>
<pre># -*- coding: UTF-8 -*-</pre>
<p>Con esa declaración, todos los caracteres serán reconocidos y no tendremos errores de caracteres no admitidos al ejecutar nuestro programa.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/pycj.wordpress.com/37/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/pycj.wordpress.com/37/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/pycj.wordpress.com/37/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/pycj.wordpress.com/37/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/pycj.wordpress.com/37/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/pycj.wordpress.com/37/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/pycj.wordpress.com/37/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/pycj.wordpress.com/37/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/pycj.wordpress.com/37/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/pycj.wordpress.com/37/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/pycj.wordpress.com/37/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/pycj.wordpress.com/37/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/pycj.wordpress.com/37/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/pycj.wordpress.com/37/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=pycj.wordpress.com&amp;blog=8684468&amp;post=37&amp;subd=pycj&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://pycj.wordpress.com/2009/10/31/primer-encuentro-con-python/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/d0fa25be2c38f9394f97011524c5c387?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">carlosj2585</media:title>
		</media:content>
	</item>
		<item>
		<title>Parece vacío, pero no&#8230; :)</title>
		<link>http://pycj.wordpress.com/2009/10/23/parece-vacio-pero-no/</link>
		<comments>http://pycj.wordpress.com/2009/10/23/parece-vacio-pero-no/#comments</comments>
		<pubDate>Fri, 23 Oct 2009 23:31:46 +0000</pubDate>
		<dc:creator>Carlos Joel</dc:creator>
				<category><![CDATA[Python]]></category>
		<category><![CDATA[Varios]]></category>

		<guid isPermaLink="false">http://pycj.wordpress.com/?p=17</guid>
		<description><![CDATA[Mmm&#8230; Hace algún tiempo que abrí este blog, y hasta ahora no escribí nada, bueno, no &#8220;afecta&#8221; mucho todavía porque nadie entra a ver este blog «todavía», pero eso no significa que no haya aprendido nada hasta ahora, ya tengo algo escrito en borrador sobre programación básica hasta el tema de Programación Orientada a Objetos, [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=pycj.wordpress.com&amp;blog=8684468&amp;post=17&amp;subd=pycj&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.python.org"><img class="alignleft size-thumbnail wp-image-19" title="python-logo" src="http://pycj.files.wordpress.com/2009/10/python-logo1.png?w=150&#038;h=148" alt="python-logo" width="150" height="148" /></a></p>
<p>Mmm&#8230; Hace algún tiempo que abrí este blog, y hasta ahora no escribí nada, bueno, no &#8220;afecta&#8221; mucho todavía porque nadie entra a ver este blog «<em>todavía</em>», pero eso no significa que no haya aprendido nada hasta ahora, ya tengo algo escrito en borrador sobre programación básica hasta el tema de Programación Orientada a Objetos, y esta semana voy a empezar a ver como maneja Python lo que es Herencia y Polimorfismo. Un dato interesante es que en Python «<em><strong>Todo es un Objeto</strong></em>».</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/pycj.wordpress.com/17/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/pycj.wordpress.com/17/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/pycj.wordpress.com/17/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/pycj.wordpress.com/17/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/pycj.wordpress.com/17/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/pycj.wordpress.com/17/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/pycj.wordpress.com/17/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/pycj.wordpress.com/17/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/pycj.wordpress.com/17/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/pycj.wordpress.com/17/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/pycj.wordpress.com/17/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/pycj.wordpress.com/17/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/pycj.wordpress.com/17/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/pycj.wordpress.com/17/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=pycj.wordpress.com&amp;blog=8684468&amp;post=17&amp;subd=pycj&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://pycj.wordpress.com/2009/10/23/parece-vacio-pero-no/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/d0fa25be2c38f9394f97011524c5c387?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">carlosj2585</media:title>
		</media:content>

		<media:content url="http://pycj.files.wordpress.com/2009/10/python-logo1.png?w=150" medium="image">
			<media:title type="html">python-logo</media:title>
		</media:content>
	</item>
		<item>
		<title>¿Python? ¡Bah!</title>
		<link>http://pycj.wordpress.com/2009/10/23/16/</link>
		<comments>http://pycj.wordpress.com/2009/10/23/16/#comments</comments>
		<pubDate>Fri, 23 Oct 2009 22:57:26 +0000</pubDate>
		<dc:creator>Carlos Joel</dc:creator>
				<category><![CDATA[Humor]]></category>
		<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://pycj.wordpress.com/2009/10/23/16/</guid>
		<description><![CDATA[<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=pycj.wordpress.com&amp;blog=8684468&amp;post=16&amp;subd=pycj&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.tiraecol.net/modules/comic/comic.php?content_id=30"><img class="aligncenter" title="Python.... :)" src="http://users.servicios.retecal.es/tjavier/python/imagenes/ecol-28.png" alt="" width="400" height="138" /></a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/pycj.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/pycj.wordpress.com/16/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/pycj.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/pycj.wordpress.com/16/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/pycj.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/pycj.wordpress.com/16/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/pycj.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/pycj.wordpress.com/16/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/pycj.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/pycj.wordpress.com/16/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/pycj.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/pycj.wordpress.com/16/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/pycj.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/pycj.wordpress.com/16/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=pycj.wordpress.com&amp;blog=8684468&amp;post=16&amp;subd=pycj&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://pycj.wordpress.com/2009/10/23/16/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/d0fa25be2c38f9394f97011524c5c387?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">carlosj2585</media:title>
		</media:content>

		<media:content url="http://users.servicios.retecal.es/tjavier/python/imagenes/ecol-28.png" medium="image">
			<media:title type="html">Python.... :)</media:title>
		</media:content>
	</item>
		<item>
		<title>Hello world!</title>
		<link>http://pycj.wordpress.com/2009/07/22/hello-world/</link>
		<comments>http://pycj.wordpress.com/2009/07/22/hello-world/#comments</comments>
		<pubDate>Wed, 22 Jul 2009 15:43:46 +0000</pubDate>
		<dc:creator>Carlos Joel</dc:creator>
				<category><![CDATA[Varios]]></category>

		<guid isPermaLink="false"></guid>
		<description><![CDATA[En este blog iré publicando todo lo que vaya aprendiendo en Python desde lo mas sencillo, hasta lo mas lejos que llegue, todo lo que haga estará sobre Linux (Ubuntu, Mandriva, Debian). print "Hello world"<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=pycj.wordpress.com&amp;blog=8684468&amp;post=1&amp;subd=pycj&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>En este blog iré publicando todo lo que vaya aprendiendo en Python desde lo mas sencillo, hasta lo mas lejos que llegue, todo lo que haga estará sobre Linux (Ubuntu, Mandriva, Debian).</p>
<blockquote><p><span style="color:#993300;"><br />
<code>print "Hello world"</code></span></p></blockquote>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/pycj.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/pycj.wordpress.com/1/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/pycj.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/pycj.wordpress.com/1/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/pycj.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/pycj.wordpress.com/1/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/pycj.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/pycj.wordpress.com/1/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/pycj.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/pycj.wordpress.com/1/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/pycj.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/pycj.wordpress.com/1/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/pycj.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/pycj.wordpress.com/1/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=pycj.wordpress.com&amp;blog=8684468&amp;post=1&amp;subd=pycj&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://pycj.wordpress.com/2009/07/22/hello-world/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/d0fa25be2c38f9394f97011524c5c387?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">carlosj2585</media:title>
		</media:content>
	</item>
	</channel>
</rss>
