<?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/"
	>

<channel>
	<title>It's not a blog, It's a feature &#187; Uncategorized</title>
	<atom:link href="http://javazquez.com/juan/category/uncategorized/feed/" rel="self" type="application/rss+xml" />
	<link>http://javazquez.com/juan</link>
	<description>Juan A. Vazquez</description>
	<lastBuildDate>Tue, 06 Apr 2010 03:43:00 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Ruby to Python Primer</title>
		<link>http://javazquez.com/juan/2008/12/16/ruby-to-python-primer/</link>
		<comments>http://javazquez.com/juan/2008/12/16/ruby-to-python-primer/#comments</comments>
		<pubDate>Tue, 16 Dec 2008 16:44:15 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[fun]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Ruby Questions]]></category>

		<guid isPermaLink="false">http://javazquez.com/juan/?p=35</guid>
		<description><![CDATA[Here is a quick list of similarities between the two languages.
#ruby
puts s.methods 

#python
print dir(s)
]]></description>
			<content:encoded><![CDATA[<p>If your like me, you bounce around between languages a lot. Lately, I have been writing python code. It&#8217;s not Ruby <img src='http://javazquez.com/juan/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' />  , but it can get the job done. Here is a quick list of similarities between the two languages. I hope it helps&#8230; don&#8217;t forget to this list in the comments section <img src='http://javazquez.com/juan/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /><br />
<code><br />
#-----find object methods-----<br />
s="hello, I am a string"</p>
<p>#ruby<br />
puts s.methods </p>
<p>#python<br />
print dir(s)</p>
<p>#find out more about a method using python<br />
help(s.split)</p>
<p>#-----view object's class-----<br />
#ruby<br />
s.class </p>
<p>#python<br />
s.__class__</p>
<p>#------Iterate hashes-------</p>
<p>#ruby<br />
h.each{|key,value| puts "#{key}, #{value}"} </p>
<p>#python<br />
for key,value in h.iteritems():<br />
  print key, value</p>
<p>#---ternary operators</p>
<p>#ruby<br />
condition ? var = x : var = y</p>
<p>#python.. not exactly an operator, but you get the meaning<br />
#---- var = y  if condition is false<br />
var = x if condition else y     </p>
<p>#----lengths------<br />
#ruby<br />
s="hello, I am a string"<br />
puts "Length of string is #{s.length} or #{s.size}" </p>
<p>h={:one=>2,:three=>4}<br />
puts "Length of hash is same as string, #{h.length} or #{h.size} "</p>
<p>#python<br />
print("This is the length of a string %s" % len("string"))<br />
print("number of key/value pair= %d" % len({'one':1,'two':2}))</p>
<p>#---slicing lists/arrays<br />
l=[1,2,3,4,5]</p>
<p>#ruby<br />
l[1..3] #=>[2,3]</p>
<p>#python<br />
l[1:3] #=>[2,3]</p>
<p>#--print string multiple times-----</p>
<p>#ruby<br />
4.times{print "hello"} #=> hellohellohellohello</p>
<p>#python<br />
print("hello" * 4) #=> hellohellohellohello</p>
<p></code></p>
]]></content:encoded>
			<wfw:commentRss>http://javazquez.com/juan/2008/12/16/ruby-to-python-primer/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
