<?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>Teguh Eko Budiarto &#187; Python</title>
	<atom:link href="http://teguheko.echodess.com/category/programming/python/feed/" rel="self" type="application/rss+xml" />
	<link>http://teguheko.echodess.com</link>
	<description>Web Programming and Sharing Experience</description>
	<lastBuildDate>Tue, 23 Aug 2011 03:58:47 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1</generator>
		<item>
		<title>Netbeans Python Intellisense</title>
		<link>http://teguheko.echodess.com/2009/10/netbeans-python-intellisense/</link>
		<comments>http://teguheko.echodess.com/2009/10/netbeans-python-intellisense/#comments</comments>
		<pubDate>Fri, 30 Oct 2009 02:07:11 +0000</pubDate>
		<dc:creator>Teguh Eko Budiarto</dc:creator>
				<category><![CDATA[IDE]]></category>
		<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://teguheko.echodess.com/?p=81</guid>
		<description><![CDATA[Since Python is not a strongly typed programming language, you do not have to specify your variable type. This is nice but have some drawback for Netbeans, which it can not recognize the type easily so you can not have good suggestion for the intellisense feature. To fix that you have to specify the type [...]]]></description>
			<content:encoded><![CDATA[<p>Since Python is not a strongly typed programming language, you do not have to specify your variable type. This is nice but have some drawback for Netbeans, which it can not recognize the type easily so you can not have good suggestion for the intellisense feature. To fix that you have to specify the type of your variable and make sure you already import the correct module.</p>
<p>For example, when you have this kind of code (below code are for example purpose only)</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
</pre></td><td class="code"><pre class="python" style="font-family:monospace;"><span style="color: #ff7700;font-weight:bold;">from</span> <span style="color: #dc143c;">datetime</span> <span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">datetime</span>
<span style="color: #ff7700;font-weight:bold;">from</span> django.<span style="color: black;">db</span> <span style="color: #ff7700;font-weight:bold;">import</span> models
<span style="color: #ff7700;font-weight:bold;">from</span> django.<span style="color: black;">utils</span>.<span style="color: black;">translation</span> <span style="color: #ff7700;font-weight:bold;">import</span> gettext_lazy <span style="color: #ff7700;font-weight:bold;">as</span> _
&nbsp;
<span style="color: #ff7700;font-weight:bold;">class</span> Poll<span style="color: black;">&#40;</span>models.<span style="color: black;">Model</span><span style="color: black;">&#41;</span>:
    question = models.<span style="color: black;">CharField</span><span style="color: black;">&#40;</span>max_length=<span style="color: #ff4500;">200</span><span style="color: black;">&#41;</span>
    password = models.<span style="color: black;">CharField</span><span style="color: black;">&#40;</span>max_length=<span style="color: #ff4500;">200</span><span style="color: black;">&#41;</span>
    pub_date = models.<span style="color: black;">DateTimeField</span><span style="color: black;">&#40;</span>_<span style="color: black;">&#40;</span><span style="color: #483d8b;">'date published'</span><span style="color: black;">&#41;</span>, 
                          default=<span style="color: #dc143c;">datetime</span>.<span style="color: black;">now</span><span style="color: black;">&#41;</span>
    <span style="color: #ff7700;font-weight:bold;">class</span> Admin:
        <span style="color: #ff7700;font-weight:bold;">pass</span>
    <span style="color: #ff7700;font-weight:bold;">def</span> <span style="color: #0000cd;">__str__</span><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;">return</span> <span style="color: #008000;">self</span>.<span style="color: black;">question</span>
    <span style="color: #ff7700;font-weight:bold;">def</span> get_choice_list<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;">return</span> <span style="color: #008000;">list</span><span style="color: black;">&#40;</span><span style="color: #008000;">self</span>.<span style="color: black;">choice_set</span>.<span style="color: black;">order_by</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'id'</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>
    <span style="color: #ff7700;font-weight:bold;">def</span> get_choice_from_num<span style="color: black;">&#40;</span><span style="color: #008000;">self</span>, choice_num<span style="color: black;">&#41;</span>:
        <span style="color: #ff7700;font-weight:bold;">try</span>:
            <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #008000;">self</span>.<span style="color: black;">get_choice_list</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><span style="color: black;">&#91;</span><span style="color: #008000;">int</span><span style="color: black;">&#40;</span>choice_num<span style="color: black;">&#41;</span>-<span style="color: #ff4500;">1</span><span style="color: black;">&#93;</span>
        <span style="color: #ff7700;font-weight:bold;">except</span> <span style="color: #008000;">IndexError</span>:
            <span style="color: #ff7700;font-weight:bold;">raise</span> Choice.<span style="color: black;">DoesNotExist</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">class</span> Choice<span style="color: black;">&#40;</span>models.<span style="color: black;">Model</span><span style="color: black;">&#41;</span>:
    poll = models.<span style="color: black;">ForeignKey</span><span style="color: black;">&#40;</span>Poll<span style="color: black;">&#41;</span>    
    choice = models.<span style="color: black;">CharField</span><span style="color: black;">&#40;</span>max_length=<span style="color: #ff4500;">200</span><span style="color: black;">&#41;</span>
    votes = models.<span style="color: black;">IntegerField</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
    <span style="color: #ff7700;font-weight:bold;">class</span> Admin:
        <span style="color: #ff7700;font-weight:bold;">pass</span>
    <span style="color: #ff7700;font-weight:bold;">def</span> <span style="color: #0000cd;">__str__</span><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;">return</span> <span style="color: #008000;">self</span>.<span style="color: black;">choice</span>
    <span style="color: #ff7700;font-weight:bold;">def</span> get_num<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;">try</span>:
            <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #008000;">self</span>.<span style="color: black;">poll</span>.<span style="color: black;">get_choice_list</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>.<span style="color: black;">index</span><span style="color: black;">&#40;</span><span style="color: #008000;">self</span><span style="color: black;">&#41;</span>+<span style="color: #ff4500;">1</span>
        <span style="color: #ff7700;font-weight:bold;">except</span> <span style="color: #008000;">ValueError</span>:
            <span style="color: #ff7700;font-weight:bold;">raise</span> Choice.<span style="color: black;">DoesNotExist</span></pre></td></tr></table></div>

<p>For people like me, usually the first thing I do when want to use a defined variable is to hit the ctrl-space button to display the Intellisense suggestion. But in this case, when I want to use functions or variables defined in the attribute <strong>poll</strong> in <strong>Choice</strong> class, it displays :<br />
<a href="http://teguheko.echodess.com/wp-content/uploads/2009/10/specify-type-netbeans-python.jpg" title="specify type netbeans python"><img src="http://teguheko.echodess.com/wp-content/uploads/2009/10/specify-type-netbeans-python-1024x346.jpg" alt="specify type netbeans python" title="specify type netbeans python" width="600" height="202" class="aligncenter size-large wp-image-82" /></a></p>
<p>Which means Netbeans does&#8217;nt understand the type and the intellisense just throw all the types available to you and it become garbage, instead of suggestion. To teach Netbeans the type of the variable, just click the <strong>Specify type of [the variable name]</strong> menu, and then type your variable&#8217;s type. After that the intellisense will give you nice result, like this picture below:<br />
<a href="http://teguheko.echodess.com/wp-content/uploads/2009/10/specified-type-netbeans-python.jpg" title="specified type netbeans python"><img src="http://teguheko.echodess.com/wp-content/uploads/2009/10/specified-type-netbeans-python.jpg" alt="specified type netbeans python" title="specified type netbeans python" width="685" height="346" class="aligncenter size-full wp-image-83" /></a></p>
<p>Other thing is to make sure you have imported your class in your file so Netbeans will recognized it properly. Hope it helps, Cheers! <img src='http://teguheko.echodess.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://teguheko.echodess.com/2009/10/netbeans-python-intellisense/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>How to make Python enable to download package from internet</title>
		<link>http://teguheko.echodess.com/2009/10/how-to-make-python-enable-to-download-package-from-internet/</link>
		<comments>http://teguheko.echodess.com/2009/10/how-to-make-python-enable-to-download-package-from-internet/#comments</comments>
		<pubDate>Sat, 10 Oct 2009 01:25:41 +0000</pubDate>
		<dc:creator>Teguh Eko Budiarto</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[networking]]></category>
		<category><![CDATA[proxy]]></category>
		<category><![CDATA[setuptools]]></category>
		<category><![CDATA[windows]]></category>

		<guid isPermaLink="false">http://teguheko.echodess.com/?p=68</guid>
		<description><![CDATA[This tip is for windows XP user ( some other windows version will also have similar procedure). If you are using an automatic configuration script for your internet setting, most probably, Python will not be able to connect to internet. This is troublesome if you want to install some packages which has dependencies which need [...]]]></description>
			<content:encoded><![CDATA[<p>This tip is for windows XP user ( some other windows version will also have similar procedure).</p>
<p>If you are using an automatic configuration script for your internet setting, most probably, Python will not be able to connect to internet. This is troublesome if you want to install some packages which has dependencies which need to be fetched from the net. You need to change your internet options setting to use the proxy address directly.</p>
<p>Below is how to do that:</p>
<ul>
<li>Go to Control Panel</li>
<li>Open Internet Options</li>
<li>Open Connection Tab</li>
<li>Click on <strong>LAN Settings</strong> button</li>
<li>Check the <em>Use a proxy server for your LAN&#8230;</em></li>
<li>Enter the <strong>proxy IP Address </strong>and its <strong>port</strong>. If you do not know where it is, ask your network administrator or just open the configuration script to find out where is the IP you need to use.</li>
<li>Press OK until all the setting windows are closed.</li>
</ul>
<p>Below is the screen shot of the internet options screen.</p>
<div id="attachment_69" class="wp-caption aligncenter" style="width: 544px"><img class="size-full wp-image-69" title="Internet Options Setting" src="http://teguheko.echodess.com/wp-content/uploads/2009/10/internetoptions.jpg" alt="Windows XP Professional Internet Options Screen" width="534" height="539" /><p class="wp-caption-text">Windows XP Professional Internet Options Screen</p></div>
]]></content:encoded>
			<wfw:commentRss>http://teguheko.echodess.com/2009/10/how-to-make-python-enable-to-download-package-from-internet/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Building Python installer from package source</title>
		<link>http://teguheko.echodess.com/2009/10/building-python-installer-from-package-source/</link>
		<comments>http://teguheko.echodess.com/2009/10/building-python-installer-from-package-source/#comments</comments>
		<pubDate>Sat, 10 Oct 2009 01:04:42 +0000</pubDate>
		<dc:creator>Teguh Eko Budiarto</dc:creator>
				<category><![CDATA[Python]]></category>
		<category><![CDATA[python package]]></category>
		<category><![CDATA[setuptools]]></category>
		<category><![CDATA[windows]]></category>

		<guid isPermaLink="false">http://teguheko.echodess.com/?p=65</guid>
		<description><![CDATA[I wrote this post in my journey to adapt Python with Django framework as my tool in the next project. A little bit skeptical and some holding back since I had background in PHP and C# .Net. But, I have no choice because Python is already team&#8217;s decision for new projects. So, here I go [...]]]></description>
			<content:encoded><![CDATA[<p>I wrote this post in my journey to adapt Python with Django framework as my tool in the next project. A little bit skeptical and some holding back since I had background in PHP and C# .Net. But, I have no choice because Python is already team&#8217;s decision for new projects. So, here I go with learning new language and framework again.</p>
<p>In the way, sometimes I can not find a distributable package for your Python version. In one case, I would like to install <a href="http://pypi.python.org/pypi/setuptools">setuptools</a> to install other packages, <a href="http://pypi.python.org/pypi/soaplib/0.8.1">soaplib</a> which I need to build a SOAP web service. This is because most of our legacy applications are using C# which using SOAP to interface with web services, otherwise, I prefer to create REST based web service. Anyway, this is just my beginner way of thinking.</p>
<p>So, enough with the mumbling, below is how it is:</p>
<ul>
<li>Unpack the source into a folder.</li>
<li>Using command prompt, go to the folder and run command below ( I assume that you already set your python PATH and can run Python command from command prompt).<strong></strong></li>
<blockquote>
<li><strong>python setup.py bdist_wininst</strong></li>
</blockquote>
<li>Voila! An executable installer for your installed Python version will be available in <strong>dist </strong>sub folder.</li>
</ul>
<p>Very easy isn&#8217;t it? Yeah, if it is that easy for me to find how in the first place, I would&#8217;nt write this post.</p>
]]></content:encoded>
			<wfw:commentRss>http://teguheko.echodess.com/2009/10/building-python-installer-from-package-source/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

