<?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>BoltPress &#187; python</title>
	<atom:link href="http://blog.novalistic.com/tag/python/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.novalistic.com</link>
	<description>Also the official blog.NOVALISTIC</description>
	<lastBuildDate>Mon, 02 Aug 2010 09:45:37 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Learned Python&#8230; with no basic knowledge</title>
		<link>http://blog.novalistic.com/archives/2007/10/learned-python-with-no-basic-knowledge/</link>
		<comments>http://blog.novalistic.com/archives/2007/10/learned-python-with-no-basic-knowledge/#comments</comments>
		<pubDate>Wed, 03 Oct 2007 07:42:24 +0000</pubDate>
		<dc:creator>BoltClock</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://blog.dev.novalistic.com/?p=109</guid>
		<description><![CDATA[If you&#8217;re not a programmer, you won&#8217;t be able to understand half of this post. You could try though, but I&#8217;m not forcing anyone. The gist of this whole post was that all I did was write a few painfully simple lines of Python, have an idea to run it through the parser, do so, [...]]]></description>
			<content:encoded><![CDATA[<p>If you&#8217;re not a programmer, you won&#8217;t be able to understand half of this post. You could try though, but I&#8217;m not forcing anyone.</p>
<p>The gist of this whole post was that all I did was write a few painfully simple lines of Python, have an idea to run it through the parser, do so, and beam at myself because the parser did things right. I was that proud simply because <strong>I&#8217;ve had absolutely <em>no</em> prior knowledge of Python at all</strong>. If something like this has occurred to you before, let me know through commenting <img src='http://blog.novalistic.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> </p>
<p>Here&#8217;s my story in full. Be warned that it might slightly bore you in the first couple paragraphs. So yesterday I was just messing with my <a href="http://dev.NOVALISTIC.com/wordpress">WordPress demo installation</a>&#8230;</p>
<p><span id="more-109"></span></p>
<p>I was writing <a href="http://dev.NOVALISTIC.com/wordpress/2007/10/01/some-code-snippets">this post on code snippets</a>, just got done with my <a href="http://www.php.net">PHP</a> snippet. Then I was considering adding in a couple more snippets for different languages: <a href="http://java.sun.com">Java</a> and <a href="http://www.python.org">Python</a>.</p>
<p>Unfortunately, <a href="http://blog.novalistic.com/downloads/wordpress-themes/sandbox-potassium">Potassium</a> currently doesn&#8217;t have a custom <code>&lt;pre&gt;</code> background image for Python (though it has one for Java) so I finally decided to drop both languages because I was too darn lazy to think of a snippet for Java since I&#8217;m only a beginner in that language. Hell, I didn&#8217;t even <strong>know</strong> any of Python <strong>at all</strong>!</p>
<p>I read only a couple of pages of Python tutorials which I didn&#8217;t even understand&#8230; or at least I didn&#8217;t <em>think</em> I did. I wrote a basic function just for the snippets post&#8230; and that was exactly when I finally chose to drop the two languages from the post.</p>
<p>But, since I had Python and its command line interpreter installed (in order to use things like the really cool <a href="http://shuffledb.sourceforge.net">iPod shuffle Database Builder</a> and the mighty fine <a href="http://www.blender.org">Blender</a> and others), I thought, <em>why don&#8217;t I give my function and script a whirl in the Python interpreter?</em> So I did.</p>
<p>It worked! It was a ridiculously simple function, constituting only six lines excluding whitespace and comments. With those, along with one more line just to test the function, since declaring just a function without doing anything else would only leave the interpreter quiet, it&#8217;s less than twenty lines.</p>
<p>Can you believe it? The only thing I knew about Python was that it&#8217;s free software and was installed on my PC and I heard it was easy to pick up, especially for beginning programmers. And suddenly I read barely three pages, proceeded to throw in less than 20 lines of code into a file and the interpreter carried out my instruction duly.</p>
<p>If you&#8217;re curious, here&#8217;s my script, a function that just calculates the factorial of any integer (the idea was taken from a Java intro tutorial which covered a factorial class). All of it. Verbatim. Straight from my file.</p>
<pre>
# Factorial function
def factorial(n):

    result = 1

    # To calculate the factorial of a number, take
    # all integers from 1 to itself and multiply them
    for i in range(n):
        j = i + 1
        result *= j

    return result

# Test our function with 100 integers
for i in range(100):
    print "%d! = %d" % (i, factorial(i))

print "done"
</pre>
<p>Well I cheated. I got to know the syntax of the last line (which incidentally does work similarly to PHP&#8217;s <code><a href="http://www.php.net/printf">printf()</a></code> function) by looking at the iPod shuffle DB Builder&#8217;s source code <img src='http://blog.novalistic.com/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' />  But that was all.</p>
<p>And yes, as of now I know Potassium still doesn&#8217;t recognize Python snippets. But it will&#8230; probably in Potassium 1.0.3 or even 1.1.0 should I deem fit.</p>
<p>Again, if something like my story has happened to you before, go ahead and leave a comment.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.novalistic.com/archives/2007/10/learned-python-with-no-basic-knowledge/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
