<?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>techniQal support &#187; Python</title>
	<atom:link href="http://www.techniqal.com/blog/category/python/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.techniqal.com/blog</link>
	<description>the Q stands for quality</description>
	<lastBuildDate>Thu, 29 Apr 2010 17:40:44 +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 and Rails Float Python&#8217;s Boat</title>
		<link>http://www.techniqal.com/blog/2008/03/04/ruby-and-rails-float-pythons-boat/</link>
		<comments>http://www.techniqal.com/blog/2008/03/04/ruby-and-rails-float-pythons-boat/#comments</comments>
		<pubDate>Wed, 05 Mar 2008 03:08:06 +0000</pubDate>
		<dc:creator>Daniel</dc:creator>
				<category><![CDATA[Python]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://www.techniqal.com/blog/2008/03/04/ruby-and-rails-float-pythons-boat/</guid>
		<description><![CDATA[Antonio over at antoniocangiano.com has a great article about the effect the rise of Rails and Ruby has had on Python. I totally agree with him regarding the meteoric rise in popularity of Rails buoying scripting languages such as python. I believe more and more businesses are choosing, or are open enough, to implement Rails [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.techniqal.com/blog/wp-content/uploads/2008/03/python_winner.gif" alt="python_winner.gif" /><br />
Antonio over at <a href="http://antoniocangiano.com">antoniocangiano.com</a> has a <a href="http://antoniocangiano.com/2008/03/04/rails-is-the-best-thing-that-ever-happened-to-python/">great article</a> about the effect the rise of Rails and Ruby has had on Python.</p>
<p>I totally agree with him regarding the meteoric rise in popularity of Rails buoying scripting languages such as python. I believe more and more businesses are choosing, or are open enough, to implement Rails and Django solutions for their webapps. On top of other MVC frameworks, both Django and Rails allow for fast and sometimes cheap development (the non-cheap comes in if you have to hire an over-priced rails consultant). The visibility is definitely changing the way businesses view scripting languages and allow them to be seen as a viable alternative to Java and other enterprise adopted technologies.</p>
<p>I have had a man-crush on python for quit some time, and try to spout off about it&#8217;s benefits whenever I can.<br />
I have been so close to starting a series of blog posts surrounding Python and the ease of adoption for the non-programmer.  As soon as I have more time&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.techniqal.com/blog/2008/03/04/ruby-and-rails-float-pythons-boat/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>My Squidoo Public Beta</title>
		<link>http://www.techniqal.com/blog/2005/12/08/my-squidoo-public-beta/</link>
		<comments>http://www.techniqal.com/blog/2005/12/08/my-squidoo-public-beta/#comments</comments>
		<pubDate>Thu, 08 Dec 2005 18:19:20 +0000</pubDate>
		<dc:creator>Daniel</dc:creator>
				<category><![CDATA[Python]]></category>
		<category><![CDATA[Software]]></category>

		<guid isPermaLink="false">http://www.techniqal.com/blog/?p=52</guid>
		<description><![CDATA[So, the word is out, and Seth Godins&#8216; latest project, Squidoo, is slightly open to the public. Those of us who were closed beta testers were given the go ahead to share our Squidoo Lenses with friends and family. For those who don&#8217;t know, Squidoo, is a site that enhances the search engine ideology. It [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://static.flickr.com/35/71525031_4de510f7a6_t.jpg" alt="squid" /><br />
So, the word is out, and <a href="http://sethgodin.typepad.com/">Seth Godins</a>&#8216; latest project, <a href="http://www.squidoo.com">Squidoo</a>, is slightly open to the public. Those of us who were closed beta testers were given the go ahead to share our Squidoo Lenses with friends and family.</p>
<p>For those who don&#8217;t know, Squidoo, is a site that enhances the search engine ideology. It does this by allowing people to publish information/links and articles(Lenses) on subjects that a person(LensMaster) may have experience/expertise in.<br />
The concept allows these self proclaimed experts to provide tightly filtered and relevant information on a topic, without all of the cruft that comes along with a normal search engine.  The whole project abounds with the hottest buzzwords of the day,ie. longtail,web 2.0, ajax,etc.</p>
<p>So I decided to do a lense about the Python programming language, and it&#8217;s use on Windows. So without any further ado, the link to my Squidoo lense.<br />
<a href="http://www.squidoo.com/python_on_windows/">http://www.squidoo.com/python_on_windows/</a></p>
<p>I am currently ranked 1,777 , &#8211;so if you believe my lense has some valuable content, go ahead and rate it.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.techniqal.com/blog/2005/12/08/my-squidoo-public-beta/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to Run a Script from Email</title>
		<link>http://www.techniqal.com/blog/2005/11/14/how-to-run-a-script-from-email/</link>
		<comments>http://www.techniqal.com/blog/2005/11/14/how-to-run-a-script-from-email/#comments</comments>
		<pubDate>Tue, 15 Nov 2005 00:56:59 +0000</pubDate>
		<dc:creator>Daniel</dc:creator>
				<category><![CDATA[Python]]></category>
		<category><![CDATA[Software]]></category>

		<guid isPermaLink="false">http://www.techniqal.com/blog/?p=48</guid>
		<description><![CDATA[Got a little idea to write this up after seeing a question over on Photo Matt. He asked about having a script that could take commands sent by email and execute them remotely, then return the results via email. So I decided to hack something up in Python, and give it a try. Read the [...]]]></description>
			<content:encoded><![CDATA[<p>Got a little idea to write this up after seeing a question over on <a href="http://photomatt.net/">Photo Matt</a>.  He asked about having a script that could take commands sent by email and execute them remotely, then return the results via email.<br />
So I decided to hack something up in Python, and give it a try. Read the rest of the post to see how I did it.<br />
Or you can cheat and just look at the script itself. <a href="http://www.techniqal.com/blog/sys_email.html">Click Here for the script</a>.</p>
<p><span id="more-48"></span><br />
First off, you will need access to the *nix server. Probably root access.<br />
This method uses a standard python script, and the sendmail smrsh facility.<br />
You will want to start by making sure sendmail has smrsh support included.<br />
You can tell if it does by looking at /etc/mail/sendmail.mc and looking for a line &#8211;FEATURE(`smrsh&#8217;,`/usr/sbin/smrsh&#8217;)<br />
If you get that far, you are in good shape.</p>
<p>Onto configuring smrsh:</p>
<ol>
<li>Create a new user account that will recieve the email. Ex: <em>adduser my_secret_user</em>
</li>
<li>Then edit /etc/aliases and add a line like:<br />
                my_secret_user: &#8220;|/etc/smrsh/my_script_name&#8221;
</li>
<li>Then run the <em>newaliases</em> command</li>
<li>Now, all you need to do is create the script. You will need it to be named whatever you called it when adding the line to the /etc/aliases  file, and it needs to be in the /etc/smrsh directory. The example script below is the one I wrote in python. You can copy the script, and alter it for your needs. And if any python zealots see this, I know it is not well formed, and could be written much better.</li>
</ol>
<pre>
<code>

#!/usr/local/bin/python
# Change the fromaddr and toaddr values below,
# and change path to python above

import sys,os,re,string,smtplib

#who the response comes from
fromaddr = 'secret@localhost'
#who to send the email to
toaddr = 'myemail@myhost.com'

input = sys.stdin
mail = input.readlines()

for x in mail:
     #  is string to denote start of command.
     #  change it below to suit your needs.
     if re.search('*cmd*',x):
            cmd = string.replace(x,'*cmd*','')
            cmd = string.strip(cmd)
            cmd_in,cmd_out = os.popen4(cmd)
            msg = 'Subject: Output from " + cmd + '\r\n'
            msg = msg + cmd_out.read()

#Optional-- this will send email to whoever sent the original,
# un-comment out next 7 lines --otherwise, this will
#only send emails to address configured  above

# if re.search('From:',x):
#    if re.search('@',x):
#       who = string.split(x,' ')
#       toaddr = who[2]
#       toaddr = string.replace(x,'< ','')
#       toaddr = string.replace(x,'>','')

#send email
if msg:
        server = smtplib.SMTP('localhost')
        server.sendmail(fromaddr,toaddr,msg)
        server.quit()

</code>
  </pre>
<p><strong>Caveats: This is probably not safe to do. Make sure the email address is obscure enough, so it could not be guessed.<br />
Also, this will run any command the exec&#8217;ing user has rights to. So if the script is owned by root, you can do some damage.<br />
Use caution, and don&#8217;t say I didn&#8217;t warn you.</strong></p>
]]></content:encoded>
			<wfw:commentRss>http://www.techniqal.com/blog/2005/11/14/how-to-run-a-script-from-email/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Creating a Task Bar icon in wxPython</title>
		<link>http://www.techniqal.com/blog/2005/07/20/creating-a-task-bar-icon-in-wxpython/</link>
		<comments>http://www.techniqal.com/blog/2005/07/20/creating-a-task-bar-icon-in-wxpython/#comments</comments>
		<pubDate>Thu, 21 Jul 2005 01:45:00 +0000</pubDate>
		<dc:creator>Daniel</dc:creator>
				<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://192.168.0.2:8000/blog/?p=3</guid>
		<description><![CDATA[Here is another nifty tidbit of python code that is often hard to find. If you work with Python and wxPython to build gui apps, there are a number of widgets etc., that can be hard to figure out. Adding a task bar icon for your app is one of them. This simple example shows [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.amazon.com/Dive-Into-Python-Mark-Pilgrim/dp/1441437134/ref=sr_1_3?ie=UTF8&amp;s=books&amp;qid=1272562697&amp;sr=1-3"><img src="/blog/wp-content/uploads/python.jpg" alt="python" class="alignleft"/></a></p>
<p>Here is another nifty tidbit of python code that is often hard to find. If you work with <a class="zem_slink" href="http://www.python.org/" title="Python (programming language)" rel="homepage">Python</a> and wxPython to build gui apps, there are a number of widgets etc., that can be hard to figure out. Adding a task bar icon for your app is one of them. This simple example shows you how to add a taskbar icon, and capture events from it.</p>
<p><span id="more-3"></span><br />
<code><br />
</code>
<pre>import wx

def OnTaskBarRight(event):
             app.ExitMainLoop()
#setup app
app= wx.PySimpleApp()

#setup icon object
icon = wx.Icon("favicon.ico", wx.BITMAP_TYPE_ICO)

#setup taskbar icon
tbicon = wx.TaskBarIcon()
tbicon.SetIcon(icon, "I am an Icon")

#add taskbar icon event
wx.EVT_TASKBAR_RIGHT_UP(tbicon, OnTaskBarRight)

app.MainLoop()
</pre>
<p>Check out the documentation for <a href="http://wxpython.org/onlinedocs.php">wxPython</a>, for more information.</p>
<div style="margin-top: 10px; height: 15px;" class="zemanta-pixie"><a class="zemanta-pixie-a" href="http://reblog.zemanta.com/zemified/6171b242-04a2-4579-ad11-2e32b765cf0c/" title="Reblog this post [with Zemanta]"><img style="border: medium none; float: right;" class="zemanta-pixie-img" src="http://img.zemanta.com/reblog_e.png?x-id=6171b242-04a2-4579-ad11-2e32b765cf0c" alt="Reblog this post [with Zemanta]"/></a><span class="zem-script more-related pretty-attribution"><script type="text/javascript" src="http://static.zemanta.com/readside/loader.js" defer="defer"></script></span></div>
]]></content:encoded>
			<wfw:commentRss>http://www.techniqal.com/blog/2005/07/20/creating-a-task-bar-icon-in-wxpython/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Great Python Articles/Tutorials</title>
		<link>http://www.techniqal.com/blog/2005/05/17/great-python-articlestutorials/</link>
		<comments>http://www.techniqal.com/blog/2005/05/17/great-python-articlestutorials/#comments</comments>
		<pubDate>Tue, 17 May 2005 18:12:07 +0000</pubDate>
		<dc:creator>Daniel</dc:creator>
				<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://www.techniqal.com/blog/?p=9</guid>
		<description><![CDATA[I thought I would throw some information out there that has helped me immensely in the past. Here is a link to some articles on Devshed.com that simplify and de-mystify some common problems people have when learning Python, from beginner on up. For beginners I suggest checking out the articles here and here for info [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://photos13.flickr.com/14220438_42c4208c5c_t.jpg" class="alignleft"/>I thought I would throw some information out there that has helped me immensely in the past. Here is a link to some articles on <a href="http://www.devshed.com/">Devshed.com</a> that simplify and de-mystify some common problems people have when learning Python, from beginner on up. For beginners I suggest checking out the articles <a href="http://www.devshed.com/c/a/Python/File-Management-in-Python/">here</a> and <a href="http://www.devshed.com/c/a/Python/Sockets-in-Python/">here</a> for info on file handling and sockets.<br />
Also, check out the forums if you are ever in need of some guidance or help in the world of <a href="http://python.org/">Python</a> , or just about any other language/technology.</p>
<p><a href="http://www.devshed.com/c/a/Python/">&#8211;List of articles&#8211;</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.techniqal.com/blog/2005/05/17/great-python-articlestutorials/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Python: Simple File Read and Write</title>
		<link>http://www.techniqal.com/blog/2005/05/17/python-simple-file-read-and-write/</link>
		<comments>http://www.techniqal.com/blog/2005/05/17/python-simple-file-read-and-write/#comments</comments>
		<pubDate>Tue, 17 May 2005 18:08:41 +0000</pubDate>
		<dc:creator>Daniel</dc:creator>
				<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://www.techniqal.com/blog/?p=8</guid>
		<description><![CDATA[Though there are a lot of resources out there for Python,and great books, rarely do you find a simple reference guide that helps you navigate the basics. I found that there was not a lot of reference material to help you do the simple things, if you didn&#8217;t know what to look for. This little [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.amazon.com/Dive-Into-Python-Mark-Pilgrim/dp/1441437134/ref=sr_1_3?ie=UTF8&#038;s=books&#038;qid=1272562697&#038;sr=1-3"><img src="/blog/wp-content/uploads/python.jpg" alt="python" class="alignleft"/></a><br />
Though there are a lot of resources out there for<span style="font-weight: bold;"> </span><a style="font-weight: bold;" href="http://python.org/">Python</a>,and <a href="http://www.amazon.com/Programming-Python-Mark-Lutz/dp/0596009259/ref=sr_1_1?ie=UTF8&amp;s=books&amp;qid=1272562363&amp;sr=8-1">great books</a>, rarely do you find a simple reference guide that helps you navigate the basics. I found that there was not a lot of reference material to help you do the simple things, if you didn&#8217;t know what to look for.</p>
<p>This little guide will focus on the basics of reading and writing files in python..<br />
<span id="more-8"></span><br />
 First we are going to focus on reading from files. Open up your Python shell,<br />
or IDE.</p>
<p>To open a file/file object :</p>
<pre>open(filename,mode)</pre>
<ol>
<li><span class="comment"></span><span style="font-style: italic;"> filename can be a file or path to a file</span></li>
<li><span class="comment"></span><span style="font-style: italic;"> mode can be any of the following</span></li>
</ol>
<ol>
<li><span class="comment"></span><span style="font-style: italic;"> &#8216;r&#8217; for reading</span></li>
<li><span class="comment"></span><span style="font-style: italic;">&#8216;r+&#8217; for reading and writing</span></li>
<li><span class="comment"></span><span style="font-style: italic;">&#8216;w&#8217; for writing</span></li>
<li><span class="comment"></span><span style="font-style: italic;">&#8216;a&#8217; for appending<br />
    </span></li>
<li><span class="comment"></span><span style="font-style: italic;">both read and write modes also have a &#8216;b&#8217; option for binary reading and writing (&#8216;rb&#8217;, or &#8216;wb&#8217;)<br />
    </span></li>
</ol>
<p>  <span class="fullpost">
<pre id="line791"><span class="comment"></span><span style="color: rgb(51, 204, 0);"></span><span style="color: rgb(0, 0, 0);">Ex:</span>
myInput = open('myfile.txt','r')</pre>
<p></span></p>
<p>This command will open the file &#8220;myfile.txt&#8221; in the current<br />
directory, in &#8220;read&#8221; mode. You can access the methods of this file<br />
using the &#8216;myInput&#8217; variable. In the example, the open command will<br />
open the file indicated in the first argument(&#8216;myfile.txt&#8217;).<br />
This argument can be a file, or the path to a file. The second<br />
argument, is the file mode.</p>
<p>Once you have a file handle(<span style="color: rgb(51, 204, 0);">myInput</span>), you can work with that<br />
file, depending on the <span style="font-style: italic;">mode</span> you opened it with. We can now start<br />
reading data from our file.</p>
<p>Ex:<br />
<span style="color: rgb(51, 204, 0);">s = myFile.read()</span> <span style="font-style: italic;">Will read entire file into a string<br />
</span><span style="color: rgb(51, 204, 0);">s = myFile.read(N) </span> <span style="font-style: italic;">Will read N bytes (1 or more) from file</span><br />
<span style="color: rgb(51, 204, 0);">s = myFile.readline()</span> <span style="font-style: italic;">Will read next line into string until end of line</span><br />
<span style="color: rgb(51, 204, 0);">L = myFile.readlines()</span>  <span style="font-style: italic;">Will read entire file into a list of strings</span></p>
]]></content:encoded>
			<wfw:commentRss>http://www.techniqal.com/blog/2005/05/17/python-simple-file-read-and-write/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
	</channel>
</rss>