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

<channel>
	<title>Web Development - SEO - Codehead</title>
	<atom:link href="http://blog.code-head.com/feed" rel="self" type="application/rss+xml" />
	<link>http://blog.code-head.com</link>
	<description>Web development and programming blog focusing on webmaster's experience with PHP, MySQL, AJAX, server performance, security, SEO and more.</description>
	<pubDate>Wed, 19 Nov 2008 22:37:17 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6.3</generator>
	<language>en</language>
			<item>
		<title>My favorite TED talk</title>
		<link>http://blog.code-head.com/my-favorite-ted-talk</link>
		<comments>http://blog.code-head.com/my-favorite-ted-talk#comments</comments>
		<pubDate>Tue, 18 Nov 2008 07:31:55 +0000</pubDate>
		<dc:creator>Codehead</dc:creator>
		
		<category><![CDATA[Fun]]></category>

		<category><![CDATA[General]]></category>

		<category><![CDATA[Space]]></category>

		<category><![CDATA[Technology]]></category>

		<guid isPermaLink="false">http://blog.code-head.com/?p=525</guid>
		<description><![CDATA[
Watch all of it 
]]></description>
			<content:encoded><![CDATA[<p><object width="425" height="344"><param name="movie" value="http://www.youtube.com/v/-Bn6Gel7yEs&#038;hl=en&#038;fs=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/-Bn6Gel7yEs&#038;hl=en&#038;fs=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="344"></embed></object></p>
<p>Watch all of it <img src='http://blog.code-head.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.code-head.com/my-favorite-ted-talk/feed</wfw:commentRss>
		</item>
		<item>
		<title>Schools *kill* creativity</title>
		<link>http://blog.code-head.com/schools-kill-creativity</link>
		<comments>http://blog.code-head.com/schools-kill-creativity#comments</comments>
		<pubDate>Sun, 16 Nov 2008 11:28:53 +0000</pubDate>
		<dc:creator>Codehead</dc:creator>
		
		<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://blog.code-head.com/?p=520</guid>
		<description><![CDATA[
]]></description>
			<content:encoded><![CDATA[<p><object width="425" height="344"><param name="movie" value="http://www.youtube.com/v/iG9CE55wbtY&#038;hl=en&#038;fs=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/iG9CE55wbtY&#038;hl=en&#038;fs=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="344"></embed></object></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.code-head.com/schools-kill-creativity/feed</wfw:commentRss>
		</item>
		<item>
		<title>Decorating Python&#8217;s sys.stdout</title>
		<link>http://blog.code-head.com/decorating-pythons-sysstdout</link>
		<comments>http://blog.code-head.com/decorating-pythons-sysstdout#comments</comments>
		<pubDate>Fri, 14 Nov 2008 06:17:14 +0000</pubDate>
		<dc:creator>Codehead</dc:creator>
		
		<category><![CDATA[Fun]]></category>

		<category><![CDATA[Programming]]></category>

		<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://blog.code-head.com/?p=516</guid>
		<description><![CDATA[Try this:

class stdoutflip:
&#160;
    def __init__&#40;self, sys&#41;:
        self.stdout = sys.stdout
        sys.stdout = self
&#160;
    def write&#40;self, txt&#41;:
        txt = list&#40;txt&#41;
        txt.reverse&#40;&#41;
   [...]]]></description>
			<content:encoded><![CDATA[<p>Try this:</p>

<div class="wp_syntax"><div class="code"><pre class="python"><span style="color: #ff7700;font-weight:bold;">class</span> stdoutflip:
&nbsp;
    <span style="color: #ff7700;font-weight:bold;">def</span> <span style="color: #0000cd;">__init__</span><span style="color: black;">&#40;</span><span style="color: #008000;">self</span>, <span style="color: #dc143c;">sys</span><span style="color: black;">&#41;</span>:
        <span style="color: #008000;">self</span>.<span style="color: black;">stdout</span> = <span style="color: #dc143c;">sys</span>.<span style="color: black;">stdout</span>
        <span style="color: #dc143c;">sys</span>.<span style="color: black;">stdout</span> = <span style="color: #008000;">self</span>
&nbsp;
    <span style="color: #ff7700;font-weight:bold;">def</span> write<span style="color: black;">&#40;</span><span style="color: #008000;">self</span>, txt<span style="color: black;">&#41;</span>:
        txt = <span style="color: #008000;">list</span><span style="color: black;">&#40;</span>txt<span style="color: black;">&#41;</span>
        txt.<span style="color: black;">reverse</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
        <span style="color: #008000;">self</span>.<span style="color: black;">stdout</span>.<span style="color: black;">write</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">''</span>.<span style="color: black;">join</span><span style="color: black;">&#40;</span>txt<span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>
&nbsp;
&nbsp;
<span style="color: #ff7700;font-weight:bold;">class</span> stdoutupper:
&nbsp;
    <span style="color: #ff7700;font-weight:bold;">def</span> <span style="color: #0000cd;">__init__</span><span style="color: black;">&#40;</span><span style="color: #008000;">self</span>, <span style="color: #dc143c;">sys</span><span style="color: black;">&#41;</span>:
        <span style="color: #008000;">self</span>.<span style="color: black;">stdout</span> = <span style="color: #dc143c;">sys</span>.<span style="color: black;">stdout</span>
        <span style="color: #dc143c;">sys</span>.<span style="color: black;">stdout</span> = <span style="color: #008000;">self</span>
&nbsp;
    <span style="color: #ff7700;font-weight:bold;">def</span> write<span style="color: black;">&#40;</span><span style="color: #008000;">self</span>, txt<span style="color: black;">&#41;</span>:
        <span style="color: #008000;">self</span>.<span style="color: black;">stdout</span>.<span style="color: black;">write</span><span style="color: black;">&#40;</span>txt.<span style="color: black;">upper</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span></pre></div></div>

<p>To test it do this:</p>

<div class="wp_syntax"><div class="code"><pre class="python">out = stdoutupper<span style="color: black;">&#40;</span>stdoutflip<span style="color: black;">&#40;</span><span style="color: #dc143c;">sys</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span></pre></div></div>

<p>Now try printing stuff:</p>

<div class="wp_syntax"><div class="code"><pre class="python"><span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">&quot;Hello Python!&quot;</span></pre></div></div>

<p> <img src='http://blog.code-head.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.code-head.com/decorating-pythons-sysstdout/feed</wfw:commentRss>
		</item>
		<item>
		<title>How to fix transparent PNGs in Internet Explorer</title>
		<link>http://blog.code-head.com/how-to-fix-transparent-pngs-in-internet-explorer</link>
		<comments>http://blog.code-head.com/how-to-fix-transparent-pngs-in-internet-explorer#comments</comments>
		<pubDate>Wed, 12 Nov 2008 22:54:22 +0000</pubDate>
		<dc:creator>Codehead</dc:creator>
		
		<category><![CDATA[Annoying Stuff]]></category>

		<category><![CDATA[JavaScript]]></category>

		<category><![CDATA[Web Browsers]]></category>

		<category><![CDATA[Web Design]]></category>

		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://blog.code-head.com/?p=514</guid>
		<description><![CDATA[You might know already that there are some issues with transparent GIFs but PNGs don&#8217;t have those issues.
The problem with transparent PNGs is that Internet Explorer doesn&#8217;t like them so much and gives them a funny background.
So here is the solution that works great:
http://homepage.ntlworld.com/bobosola/index.htm
]]></description>
			<content:encoded><![CDATA[<p>You might know already that there are some issues with transparent GIFs but PNGs don&#8217;t have those issues.<br />
The problem with transparent PNGs is that Internet Explorer doesn&#8217;t like them so much and gives them a funny background.</p>
<p>So here is the solution that works great:<br />
<a href="http://homepage.ntlworld.com/bobosola/index.htm">http://homepage.ntlworld.com/bobosola/index.htm</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.code-head.com/how-to-fix-transparent-pngs-in-internet-explorer/feed</wfw:commentRss>
		</item>
		<item>
		<title>Computers of the future</title>
		<link>http://blog.code-head.com/computers-of-the-future</link>
		<comments>http://blog.code-head.com/computers-of-the-future#comments</comments>
		<pubDate>Wed, 12 Nov 2008 20:18:15 +0000</pubDate>
		<dc:creator>Codehead</dc:creator>
		
		<category><![CDATA[Fun]]></category>

		<category><![CDATA[General]]></category>

		<category><![CDATA[Operating Systems]]></category>

		<guid isPermaLink="false">http://blog.code-head.com/?p=509</guid>
		<description><![CDATA[They are going to be just a monitor, a touch screen monitor, there will be a keyboard on the screen if you want to type anything, there will be no keyboard, mouse or touch pad.
Probably in the next 5 years they will be everywhere, you might not be able to buy one of these either [...]]]></description>
			<content:encoded><![CDATA[<p>They are going to be just a monitor, a touch screen monitor, there will be a keyboard on the screen if you want to type anything, there will be no keyboard, mouse or touch pad.<br />
Probably in the next 5 years they will be everywhere, you might not be able to buy one of these either <img src='http://blog.code-head.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p><object width="425" height="344"><param name="movie" value="http://www.youtube.com/v/GqDQ0wUcSPQ&#038;hl=en&#038;fs=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/GqDQ0wUcSPQ&#038;hl=en&#038;fs=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="344"></embed></object></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.code-head.com/computers-of-the-future/feed</wfw:commentRss>
		</item>
		<item>
		<title>My problem with Microsoft and their products</title>
		<link>http://blog.code-head.com/my-problem-with-microsoft-and-their-products</link>
		<comments>http://blog.code-head.com/my-problem-with-microsoft-and-their-products#comments</comments>
		<pubDate>Wed, 12 Nov 2008 19:31:02 +0000</pubDate>
		<dc:creator>Codehead</dc:creator>
		
		<category><![CDATA[Annoying Stuff]]></category>

		<category><![CDATA[General]]></category>

		<category><![CDATA[Programming]]></category>

		<category><![CDATA[Web Browsers]]></category>

		<guid isPermaLink="false">http://blog.code-head.com/?p=510</guid>
		<description><![CDATA[A while back, I wrote two posts about Microsoft and I wrote them when I was upset so it might have offended people.
To be honest with you, I was a fan of Microsoft and their products up until Internet Explorer 7 came along.
I installed it on two computers and I had to disable all the [...]]]></description>
			<content:encoded><![CDATA[<p>A while back, I wrote two posts about Microsoft and I wrote them when I was upset so it might have offended people.</p>
<p>To be honest with you, I was a fan of Microsoft and their products up until Internet Explorer 7 came along.<br />
I installed it on two computers and I had to disable all the addons other than the essentials in order to make them run smoothly and without so much issues.</p>
<p>Right now, my Internet Explorer process grows until it&#8217;s 1GB in size!!! and it then gets so slow or crashes and I loose all my open tabs and what ever I was doing.<br />
It also crashed every once in a while for some reason and it&#8217;s still not standard compliant.</p>
<p>About Windows Vista; we also bought four computers with Vista and every single one, without an exception had issues right out of the box, big issues that I think Microsoft should have known about but shipped the product anyway.</p>
<p>Honestly, this is disappointing for me, because I liked Windows and it&#8217;s openness and the ability for everyone to write great applications for it and it&#8217;s huge documentation on Microsoft website.</p>
<p>I also think that Microsoft contributed a lot to the industry and I hope that this is not the end of it.</p>
<p>I&#8217;m a software developer and I don&#8217;t consider myself to be the best one but I know one thing, we don&#8217;t EVER ship until we fix all the obvious bugs, if we did, we wouldn&#8217;t have any clients right now.</p>
<p>Good Luck <img src='http://blog.code-head.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.code-head.com/my-problem-with-microsoft-and-their-products/feed</wfw:commentRss>
		</item>
		<item>
		<title>Python as CGI and Error 500, Internal Server Error</title>
		<link>http://blog.code-head.com/python-as-cgi-and-error-500-internal-server-error</link>
		<comments>http://blog.code-head.com/python-as-cgi-and-error-500-internal-server-error#comments</comments>
		<pubDate>Mon, 10 Nov 2008 06:28:35 +0000</pubDate>
		<dc:creator>Codehead</dc:creator>
		
		<category><![CDATA[Annoying Stuff]]></category>

		<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://blog.code-head.com/?p=507</guid>
		<description><![CDATA[If you have this problem on *nix systems, these are the things to look for:
1 - Make sure your line breaks are \n not \r\n you can set this in almost all editors, you will have to either select *nix like line breaks or \n somewhere in your editor preferences.
2 - After the first step [...]]]></description>
			<content:encoded><![CDATA[<p>If you have this problem on *nix systems, these are the things to look for:</p>
<p>1 - Make sure your line breaks are \n not \r\n you can set this in almost all editors, you will have to either select *nix like line breaks or \n somewhere in your editor preferences.</p>
<p>2 - After the first step you will have to make sure that your FTP client uploads the files in ASCII format and this will insure that \n will stay \n.</p>
<p>3 - If it still doesn&#8217;t work, make sure your Python script&#8217;s permissions are 755. You can try:<br />
chmod 755 your_python_script.py</p>
<p>Or use your FTP client to fix this. (Refer to it&#8217;s documentation but usually you can right click on the file, on your server and click properties)</p>
<p>4 - If you still have the problem, you will have to have the right shebang line in the beginning of your script, the most common one is:<br />
#!/usr/bin/env python<br />
If this doesn&#8217;t work try:<br />
#!/usr/bin/python<br />
Or:<br />
#!/usr/local/bin/python<br />
Note that, this must be the first line</p>
<p>5 - If none of these worked and you have root access to your server, try:<br />
tail -f /usr/local/apache/logs/error_log      (Note that, the path to Apache error log might be different on your server)<br />
And look for the error message associated with your request.</p>
<p>6 - If you still can&#8217;t figure it out, write to your hosting company and ask them.</p>
<p>I hope this helps <img src='http://blog.code-head.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.code-head.com/python-as-cgi-and-error-500-internal-server-error/feed</wfw:commentRss>
		</item>
		<item>
		<title>Let&#8217;s make Python web friendly</title>
		<link>http://blog.code-head.com/lets-make-python-web-friendly</link>
		<comments>http://blog.code-head.com/lets-make-python-web-friendly#comments</comments>
		<pubDate>Sat, 08 Nov 2008 18:48:20 +0000</pubDate>
		<dc:creator>Codehead</dc:creator>
		
		<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://blog.code-head.com/?p=499</guid>
		<description><![CDATA[Here is a great language, so powerful and fun to write code with yet it&#8217;s not really being used for developing web applications.
There is no easy way to run your Python scripts like PHP, you will either have to run them as CGI and there is a lot of pain associated with that if you [...]]]></description>
			<content:encoded><![CDATA[<p>Here is a great language, so powerful and fun to write code with yet it&#8217;s not really being used for developing web applications.</p>
<p>There is no easy way to run your Python scripts like PHP, you will either have to run them as CGI and there is a lot of pain associated with that if you know what I mean, sometimes you only get &#8220;Internal Server Error&#8221; and you have to pull your hair out until you find out what the problem is.</p>
<p>The other thing you can do is to use something like mod_python, which is almost impossible for an average user to install and it imposes some restrictions on you. For example, you have to have certain methods with certain names and mod_python will call those for you.</p>
<p>I&#8217;m in the process of starting to make a module for Apache (and the Lighty and then IIS hopefully) that has three great qualities that will help getting Python out there for web developers to try:</p>
<p>1 - It will install very, very, very easily on all platforms, it will be ready to go, no pain. The server admin just runs install and it&#8217;s there, ready to use.</p>
<p>2 - It doesn&#8217;t do anything fancy, nothing fancy, it only hands over the Python script to the Python interpreter and writes the output to Apache, that&#8217;s it.</p>
<p>3 - You can put your Python scripts anywhere you want just like PHP.</p>
<p>The goals of this project:</p>
<p>1 - To make Python readily available for anyone to try, without a lot of pain, as easy as PHP.</p>
<p>2 - To have this new Python module installed on all the hosting packages.</p>
<p>3 - To have this new Python module be part of all Linux distributions.</p>
<p>4 - To have a lot of web developers finally using it and enjoying it.</p>
<p>5 - To start the development of a lot of open source web apps written in Python.</p>
<p>If you want to help me with this, leave a comment, you don&#8217;t have to be a C wizard.<br />
Otherwise, please help me spread the word in any way you want.</p>
<p>Thanks!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.code-head.com/lets-make-python-web-friendly/feed</wfw:commentRss>
		</item>
		<item>
		<title>Python: understanding/reading list comprehensions</title>
		<link>http://blog.code-head.com/python-understandingreading-list-comprehensions</link>
		<comments>http://blog.code-head.com/python-understandingreading-list-comprehensions#comments</comments>
		<pubDate>Thu, 06 Nov 2008 20:08:19 +0000</pubDate>
		<dc:creator>Codehead</dc:creator>
		
		<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://blog.code-head.com/?p=493</guid>
		<description><![CDATA[List comprehensions in Python can be tricky and hard to look at but once you know the secret, it will become very clear, for example, say we have a list:

a = &#91;1, 2, 3, 4, 5&#93;

And we want to make a second list out of this &#8220;b&#8221; with values of &#8220;a&#8221; plus 2, so we [...]]]></description>
			<content:encoded><![CDATA[<p>List comprehensions in Python can be tricky and hard to look at but once you know the secret, it will become very clear, for example, say we have a list:</p>

<div class="wp_syntax"><div class="code"><pre class="python">a = <span style="color: black;">&#91;</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: black;">&#93;</span></pre></div></div>

<p>And we want to make a second list out of this &#8220;b&#8221; with values of &#8220;a&#8221; plus 2, so we want to get this:</p>

<div class="wp_syntax"><div class="code"><pre class="python">b = <span style="color: black;">&#91;</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: black;">&#93;</span></pre></div></div>

<p>Now, the way to do this without using any fancy feature would be:</p>

<div class="wp_syntax"><div class="code"><pre class="python">b = <span style="color: black;">&#91;</span><span style="color: black;">&#93;</span>
<span style="color: #ff7700;font-weight:bold;">for</span> item <span style="color: #ff7700;font-weight:bold;">in</span> a:
    b.<span style="color: black;">append</span><span style="color: black;">&#40;</span>item + <span style="color: #ff4500;">2</span><span style="color: black;">&#41;</span></pre></div></div>

<p>To turn this into a list comprehension we will start like this:</p>

<div class="wp_syntax"><div class="code"><pre class="python">b = <span style="color: black;">&#91;</span><span style="color: #ff7700;font-weight:bold;">for</span> item <span style="color: #ff7700;font-weight:bold;">in</span> a<span style="color: black;">&#93;</span></pre></div></div>

<p>Now, we will have to add our &#8220;item + 2&#8243; to the left side of the for loop so:</p>

<div class="wp_syntax"><div class="code"><pre class="python">b = <span style="color: black;">&#91;</span>item + <span style="color: #ff4500;">2</span> <span style="color: #ff7700;font-weight:bold;">for</span> item <span style="color: #ff7700;font-weight:bold;">in</span> a<span style="color: black;">&#93;</span></pre></div></div>

<p>If you didn&#8217;t understand what happened, don&#8217;t worry, just keep reading.<br />
Now, let&#8217;s look at another example, this time, we will try to understand a list comprehension that&#8217;s already written, a very simple one:</p>

<div class="wp_syntax"><div class="code"><pre class="python">a = <span style="color: black;">&#91;</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: black;">&#93;</span>
b = <span style="color: black;">&#91;</span>x<span style="color: #66cc66;">*</span>x<span style="color: #66cc66;">*</span>x <span style="color: #ff7700;font-weight:bold;">for</span> x <span style="color: #ff7700;font-weight:bold;">in</span> a<span style="color: black;">&#93;</span></pre></div></div>

<p>To read this, start form right to left:</p>

<div class="wp_syntax"><div class="code"><pre class="python"><span style="color: #ff7700;font-weight:bold;">for</span> x <span style="color: #ff7700;font-weight:bold;">in</span> a: x<span style="color: #66cc66;">*</span>x<span style="color: #66cc66;">*</span>x</pre></div></div>

<p>Internally, this will be translated to something like:</p>

<div class="wp_syntax"><div class="code"><pre class="python">b = <span style="color: black;">&#91;</span><span style="color: black;">&#93;</span>
<span style="color: #ff7700;font-weight:bold;">for</span> x <span style="color: #ff7700;font-weight:bold;">in</span> a:
    b.<span style="color: black;">append</span><span style="color: black;">&#40;</span>x<span style="color: #66cc66;">*</span>x<span style="color: #66cc66;">*</span>x<span style="color: black;">&#41;</span></pre></div></div>

<p>So the secret is to read from right to left. </p>
<p>If there should be a condition, it will come after the for loop so to increment all the items that are greater than 4 by 2:</p>

<div class="wp_syntax"><div class="code"><pre class="python">b = <span style="color: black;">&#91;</span>item + <span style="color: #ff4500;">2</span> <span style="color: #ff7700;font-weight:bold;">for</span> item <span style="color: #ff7700;font-weight:bold;">in</span> a <span style="color: #ff7700;font-weight:bold;">if</span> item <span style="color: #66cc66;">&gt;</span> <span style="color: #ff4500;">4</span><span style="color: black;">&#93;</span></pre></div></div>

<p>I hope this helps <img src='http://blog.code-head.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.code-head.com/python-understandingreading-list-comprehensions/feed</wfw:commentRss>
		</item>
		<item>
		<title>Print without a new line or space in Python</title>
		<link>http://blog.code-head.com/print-without-a-new-line-or-space-in-python</link>
		<comments>http://blog.code-head.com/print-without-a-new-line-or-space-in-python#comments</comments>
		<pubDate>Thu, 06 Nov 2008 19:17:38 +0000</pubDate>
		<dc:creator>Codehead</dc:creator>
		
		<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://blog.code-head.com/?p=491</guid>
		<description><![CDATA[Here is another little trick in Python; the print statement always inserts a line break after it prints your text, for example:

print &#34;Hello&#34;
print &#34;Python&#34;
print &#34;!&#34;

Will print:
Hello
Python
!
Now, you can fix the issue with the line break by inserting a comma after the print statement:

print &#34;Hello&#34;,
print &#34;Python&#34;,
print &#34;!&#34;

This will print:
Hello Python !
But the problem is that it [...]]]></description>
			<content:encoded><![CDATA[<p>Here is another little trick in Python; the print statement always inserts a line break after it prints your text, for example:</p>

<div class="wp_syntax"><div class="code"><pre class="python"><span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">&quot;Hello&quot;</span>
<span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">&quot;Python&quot;</span>
<span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">&quot;!&quot;</span></pre></div></div>

<p>Will print:<br />
Hello<br />
Python<br />
!</p>
<p>Now, you can fix the issue with the line break by inserting a comma after the print statement:</p>

<div class="wp_syntax"><div class="code"><pre class="python"><span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">&quot;Hello&quot;</span>,
<span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">&quot;Python&quot;</span>,
<span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">&quot;!&quot;</span></pre></div></div>

<p>This will print:<br />
Hello Python !</p>
<p>But the problem is that it will still insert a space after it prints the text, so to fix this you will have to use sys.stdout.write like this:</p>

<div class="wp_syntax"><div class="code"><pre class="python"><span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">sys</span>
<span style="color: #dc143c;">sys</span>.<span style="color: black;">stdout</span>.<span style="color: black;">write</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;Hello &quot;</span><span style="color: black;">&#41;</span>
<span style="color: #dc143c;">sys</span>.<span style="color: black;">stdout</span>.<span style="color: black;">write</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;Python&quot;</span><span style="color: black;">&#41;</span>
<span style="color: #dc143c;">sys</span>.<span style="color: black;">stdout</span>.<span style="color: black;">write</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;!&quot;</span><span style="color: black;">&#41;</span></pre></div></div>

<p>This will print:<br />
Hello Python!</p>
<p>Have fun with Python <img src='http://blog.code-head.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.code-head.com/print-without-a-new-line-or-space-in-python/feed</wfw:commentRss>
		</item>
		<item>
		<title>__FILE__ equivalent in Python; get the path to current file in Python</title>
		<link>http://blog.code-head.com/__file__-equivalent-in-python-get-the-path-to-current-file-in-python</link>
		<comments>http://blog.code-head.com/__file__-equivalent-in-python-get-the-path-to-current-file-in-python#comments</comments>
		<pubDate>Thu, 06 Nov 2008 19:09:39 +0000</pubDate>
		<dc:creator>Codehead</dc:creator>
		
		<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://blog.code-head.com/?p=489</guid>
		<description><![CDATA[There is no __FILE__ in Python as far as I know and I think there should be something similar.
It&#8217;s really handy some times and some things I like to do are impossible without it.
Python alternative to __FILE__ is this:

import inspect
this_file = inspect.currentframe&#40;&#41;.f_code.co_filename

I hope this helps 
]]></description>
			<content:encoded><![CDATA[<p>There is no __FILE__ in Python as far as I know and I think there should be something similar.<br />
It&#8217;s really handy some times and some things I like to do are impossible without it.</p>
<p>Python alternative to __FILE__ is this:</p>

<div class="wp_syntax"><div class="code"><pre class="python"><span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">inspect</span>
this_file = <span style="color: #dc143c;">inspect</span>.<span style="color: black;">currentframe</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>.<span style="color: black;">f_code</span>.<span style="color: black;">co_filename</span></pre></div></div>

<p>I hope this helps <img src='http://blog.code-head.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.code-head.com/__file__-equivalent-in-python-get-the-path-to-current-file-in-python/feed</wfw:commentRss>
		</item>
		<item>
		<title>Dynamically adding methods to objects in Python</title>
		<link>http://blog.code-head.com/dynamically-adding-methods-to-objects-in-python</link>
		<comments>http://blog.code-head.com/dynamically-adding-methods-to-objects-in-python#comments</comments>
		<pubDate>Wed, 05 Nov 2008 11:18:23 +0000</pubDate>
		<dc:creator>Codehead</dc:creator>
		
		<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://blog.code-head.com/?p=487</guid>
		<description><![CDATA[The trick is that you have to add the function to the class not the instance to see how, run your interpreter and write these:

class test:
	def __init__&#40;self&#41;:
		self.yes = &#34;Hello Python!&#34;
&#160;
def a&#40;self&#41;:
	print self.yes
&#160;
t = test&#40;&#41;
t.b = a
t.b&#40;&#41;

When this runs, you get:
Traceback (most recent call last):
  File &#8220;
&#8220;, line 1, in 
    t.b()
TypeError: [...]]]></description>
			<content:encoded><![CDATA[<p>The trick is that you have to add the function to the class not the instance to see how, run your interpreter and write these:</p>

<div class="wp_syntax"><div class="code"><pre class="python"><span style="color: #ff7700;font-weight:bold;">class</span> <span style="color: #dc143c;">test</span>:
	<span style="color: #ff7700;font-weight:bold;">def</span> <span style="color: #0000cd;">__init__</span><span style="color: black;">&#40;</span><span style="color: #008000;">self</span><span style="color: black;">&#41;</span>:
		<span style="color: #008000;">self</span>.<span style="color: black;">yes</span> = <span style="color: #483d8b;">&quot;Hello Python!&quot;</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">def</span> a<span style="color: black;">&#40;</span><span style="color: #008000;">self</span><span style="color: black;">&#41;</span>:
	<span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #008000;">self</span>.<span style="color: black;">yes</span>
&nbsp;
t = <span style="color: #dc143c;">test</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
t.<span style="color: black;">b</span> = a
t.<span style="color: black;">b</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span></pre></div></div>

<p>When this runs, you get:</p>
<p><span style="color:red;">Traceback (most recent call last):<br />
  File &#8220;
<pyshell#17>&#8220;, line 1, in <module><br />
    t.b()<br />
TypeError: b() takes exactly 1 argument (0 given)</span></p>
<p>To fix this, you will have to assign the function a to the class itself (test) not the instance (t) like:</p>

<div class="wp_syntax"><div class="code"><pre class="python"><span style="color: #dc143c;">test</span>.<span style="color: black;">b</span> = a
t = <span style="color: #dc143c;">test</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
t.<span style="color: black;">b</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span></pre></div></div>

<p>Python is fun <img src='http://blog.code-head.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.code-head.com/dynamically-adding-methods-to-objects-in-python/feed</wfw:commentRss>
		</item>
		<item>
		<title>Happy Halloween</title>
		<link>http://blog.code-head.com/happy-halloween</link>
		<comments>http://blog.code-head.com/happy-halloween#comments</comments>
		<pubDate>Fri, 31 Oct 2008 20:55:25 +0000</pubDate>
		<dc:creator>Codehead</dc:creator>
		
		<category><![CDATA[Fun]]></category>

		<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://blog.code-head.com/?p=479</guid>
		<description><![CDATA[Happy Halloween, I still have to go get some treats  I have so much work too but I decided to work on Saturday too, it&#8217;s great to be a freelancer!
]]></description>
			<content:encoded><![CDATA[<p>Happy Halloween, I still have to go get some treats <img src='http://blog.code-head.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> I have so much work too but I decided to work on Saturday too, it&#8217;s great to be a freelancer!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.code-head.com/happy-halloween/feed</wfw:commentRss>
		</item>
		<item>
		<title>One Problem With Python</title>
		<link>http://blog.code-head.com/one-problem-with-python</link>
		<comments>http://blog.code-head.com/one-problem-with-python#comments</comments>
		<pubDate>Fri, 31 Oct 2008 20:53:11 +0000</pubDate>
		<dc:creator>Codehead</dc:creator>
		
		<category><![CDATA[PHP]]></category>

		<category><![CDATA[Programming]]></category>

		<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://blog.code-head.com/?p=481</guid>
		<description><![CDATA[I think one problem Python has is the lack of a great online manual, with great I mean like PHP&#8217;s:
http://www.php.net/manual/en/function.ftp-alloc.php
Every single function is documented with examples and I think this is one of the main reasons why PHP is so popular.
]]></description>
			<content:encoded><![CDATA[<p>I think one problem Python has is the lack of a great online manual, with great I mean like PHP&#8217;s:<br />
<a href="http://www.php.net/manual/en/function.ftp-alloc.php">http://www.php.net/manual/en/function.ftp-alloc.php</a></p>
<p>Every single function is documented with examples and I think this is one of the main reasons why PHP is so popular.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.code-head.com/one-problem-with-python/feed</wfw:commentRss>
		</item>
		<item>
		<title>A PHP Competition</title>
		<link>http://blog.code-head.com/a-php-competition</link>
		<comments>http://blog.code-head.com/a-php-competition#comments</comments>
		<pubDate>Tue, 28 Oct 2008 20:24:05 +0000</pubDate>
		<dc:creator>Codehead</dc:creator>
		
		<category><![CDATA[Fun]]></category>

		<category><![CDATA[PHP]]></category>

		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://blog.code-head.com/?p=474</guid>
		<description><![CDATA[OK, here is the competition:
Write the shortest piece of PHP code to convert:
Lorem_ipsum_dolor_sit amet,_consectetur_adipisicing_elit
Into this:
Lorem_Ipsum_Dolor_Sit amet,_Consectetur_Adipisicing_Elit
There is no prize other than I will write a post about you 
Leave a comment.
Update:
Chris wrote a perfectly working line of code for the first string I posted, but you will have to write one that will still work [...]]]></description>
			<content:encoded><![CDATA[<p>OK, here is the competition:</p>
<p>Write the shortest piece of PHP code to convert:<br />
Lorem_ipsum_dolor_sit amet,_consectetur_adipisicing_elit</p>
<p>Into this:<br />
Lorem_Ipsum_Dolor_Sit amet,_Consectetur_Adipisicing_Elit</p>
<p>There is no prize other than I will write a post about you <img src='http://blog.code-head.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /><br />
Leave a comment.</p>
<p>Update:<br />
Chris wrote a perfectly working line of code for the first string I posted, but you will have to write one that will still work if there is a space in one of the words. I fixed the example.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.code-head.com/a-php-competition/feed</wfw:commentRss>
		</item>
	</channel>
</rss>
