<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-1497521753902285776</id><updated>2012-02-17T01:46:43.579+05:30</updated><category term='Log files'/><category term='Mail Server'/><category term='ubuntu'/><category term='diff and patch'/><category term='Network manager'/><title type='text'>JAGDEEP SINGH MALHI</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://jagdeepmalhi.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1497521753902285776/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://jagdeepmalhi.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><link rel='next' type='application/atom+xml' href='http://www.blogger.com/feeds/1497521753902285776/posts/default?start-index=101&amp;max-results=100'/><author><name>jagdeepsinghmalhi</name><uri>http://www.blogger.com/profile/08521786673136153319</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='26' src='http://1.bp.blogspot.com/_cKWqnDTAg-4/StdboO4vVMI/AAAAAAAAAAk/zqhdKK1K8vQ/S220/Photo%24072.jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>103</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-1497521753902285776.post-387902920112167011</id><published>2011-10-16T16:05:00.000+05:30</published><updated>2011-10-16T16:05:52.695+05:30</updated><category scheme='http://www.blogger.com/atom/ns#' term='Log files'/><title type='text'>Common Linux log files name and usage</title><content type='html'>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;/var/log/message: General message and system related stuff&lt;/li&gt;&lt;li&gt;/var/log/auth.log: Authenication logs&lt;/li&gt;&lt;li&gt;/var/log/kern.log: Kernel logs&lt;/li&gt;&lt;li&gt;/var/log/cron.log: Crond logs (cron job)&lt;/li&gt;&lt;li&gt;/var/log/maillog: Mail server logs&lt;/li&gt;&lt;li&gt;/var/log/qmail/ : Qmail log directory (more files inside this directory)&lt;/li&gt;&lt;li&gt;/var/log/httpd/: Apache access and error logs directory&lt;/li&gt;&lt;li&gt;/var/log/lighttpd: Lighttpd access and error logs directory&lt;/li&gt;&lt;li&gt;/var/log/boot.log : System boot log&lt;/li&gt;&lt;li&gt;/var/log/mysqld.log: MySQL database server log file&lt;/li&gt;&lt;li&gt;/var/log/secure: Authentication log&lt;/li&gt;&lt;li&gt;/var/log/utmp   or /var/log/wtmp : Login records files&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1497521753902285776-387902920112167011?l=jagdeepmalhi.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jagdeepmalhi.blogspot.com/feeds/387902920112167011/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://jagdeepmalhi.blogspot.com/2011/10/common-linux-log-files-name-and-usage.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1497521753902285776/posts/default/387902920112167011'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1497521753902285776/posts/default/387902920112167011'/><link rel='alternate' type='text/html' href='http://jagdeepmalhi.blogspot.com/2011/10/common-linux-log-files-name-and-usage.html' title='Common Linux log files name and usage'/><author><name>jagdeepsinghmalhi</name><uri>http://www.blogger.com/profile/08521786673136153319</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='26' src='http://1.bp.blogspot.com/_cKWqnDTAg-4/StdboO4vVMI/AAAAAAAAAAk/zqhdKK1K8vQ/S220/Photo%24072.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1497521753902285776.post-5926481223863625083</id><published>2011-10-14T08:35:00.000+05:30</published><updated>2011-10-14T08:35:11.619+05:30</updated><title type='text'>Postfix Flush the Mail Queue commands</title><content type='html'>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;&lt;code&gt;# postfix flush&lt;/code&gt;&lt;br /&gt;&lt;code&gt;&lt;/code&gt;&lt;br /&gt;&lt;code&gt;To see mail queue, enter:&lt;/code&gt;&lt;br /&gt;&lt;code&gt;# mailq&lt;/code&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;&lt;code&gt;To remove all mail from the queue, enter:&lt;/code&gt;&lt;br /&gt;&lt;code&gt;# postsuper -d ALL&lt;/code&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;code&gt;To remove all mails in the deferred queue, enter:&lt;/code&gt;&lt;br /&gt;&lt;code&gt;# postsuper -d ALL deferred&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1497521753902285776-5926481223863625083?l=jagdeepmalhi.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jagdeepmalhi.blogspot.com/feeds/5926481223863625083/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://jagdeepmalhi.blogspot.com/2011/10/postfix-flush-mail-queue-commands.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1497521753902285776/posts/default/5926481223863625083'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1497521753902285776/posts/default/5926481223863625083'/><link rel='alternate' type='text/html' href='http://jagdeepmalhi.blogspot.com/2011/10/postfix-flush-mail-queue-commands.html' title='Postfix Flush the Mail Queue commands'/><author><name>jagdeepsinghmalhi</name><uri>http://www.blogger.com/profile/08521786673136153319</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='26' src='http://1.bp.blogspot.com/_cKWqnDTAg-4/StdboO4vVMI/AAAAAAAAAAk/zqhdKK1K8vQ/S220/Photo%24072.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1497521753902285776.post-7263483300741780921</id><published>2011-08-31T10:22:00.004+05:30</published><updated>2011-09-01T10:56:36.338+05:30</updated><category scheme='http://www.blogger.com/atom/ns#' term='Mail Server'/><category scheme='http://www.blogger.com/atom/ns#' term='ubuntu'/><title type='text'>Install and Configure Mail Server on Linux System</title><content type='html'>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;&lt;b&gt;Mail Transfer Agent&lt;/b&gt;&lt;br /&gt;A Mail Transfer Agent (MTA) is the program which receives and sends out the email from your server, and is therefore the key part. The default MTA in Ubuntu is Postfix, but exim4 is also fully supported and in the main repository.&lt;br /&gt;Postfix - this guide explains how to set up Postfix.&lt;br /&gt;&lt;br /&gt;In order to install Postfix with SMTP-AUTH and TLS, first install the postfix package from the Main repository using your favorite package manager. For example:&lt;br /&gt;sudo aptitude install postfix&lt;br /&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;Configuration&lt;/b&gt;&lt;br /&gt;From a terminal prompt:&lt;br /&gt;sudo dpkg-reconfigure postfix&lt;br /&gt;Insert the following details when asked (replacing server1.example.com with your domain name if you have one):&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;General type of mail configuration: Internet Site&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;NONE doesn't appear to be requested in current config&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;System mail name: server1.example.com&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;Root and postmaster mail recipient: &amp;lt;admin_user_name&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;Other destinations for mail: server1.example.com, example.com, localhost.example.com, localhost&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;Force synchronous updates on mail queue?: No&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;Local networks: 127.0.0.0/8&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;Yes doesn't appear to be requested in current config&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;Mailbox size limit (bytes): 0&amp;nbsp;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;Local address extension character: +&amp;nbsp;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;Internet protocols to use: all&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;a name='more'&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;To configure the mailbox format for Maildir:&amp;nbsp;&lt;/b&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;sudo postconf -e 'home_mailbox = Maildir/'&lt;/span&gt;&lt;br /&gt;You may need to issue this as well:&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;sudo postconf -e 'mailbox_command ='&lt;/span&gt;&lt;br /&gt;Note: This will place new mail in /home/username/Maildir so you will need to configure your Mail Delivery Agent to use the same path.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Configure Postfix to do SMTP AUTH using SASL (saslauthd):&lt;/b&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;sudo postconf -e 'smtpd_sasl_local_domain ='&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;sudo postconf -e 'smtpd_sasl_auth_enable = yes'&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;sudo postconf -e 'smtpd_sasl_security_options = noanonymous'&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;sudo postconf -e 'broken_sasl_auth_clients = yes'&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;sudo postconf -e 'smtpd_recipient_restrictions = permit_sasl_authenticated,permit_mynetworks,reject_unauth_destination'&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;sudo postconf -e 'inet_interfaces = all'&lt;/span&gt;&lt;br /&gt;Next edit /etc/postfix/sasl/smtpd.conf and add the following lines:&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;pwcheck_method: saslauthd&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;mech_list: plain login&lt;/span&gt;&lt;br /&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;Generate certificates to be used for TLS encryption and/or certificate Authentication:&amp;nbsp;&lt;/b&gt;&lt;br /&gt;t&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;ouch smtpd.key&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;chmod 600 smtpd.key&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;openssl genrsa 1024 &amp;gt; smtpd.key&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;openssl req -new -key smtpd.key -x509 -days 3650 -out smtpd.crt # has prompts&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;openssl req -new -x509 -extensions v3_ca -keyout cakey.pem -out cacert.pem -days 3650 # has prompts&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;sudo mv smtpd.key /etc/ssl/private/&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;sudo mv smtpd.crt /etc/ssl/certs/&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;sudo mv cakey.pem /etc/ssl/private/&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;sudo mv cacert.pem /etc/ssl/certs/&lt;/span&gt;&lt;br /&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;Configure Postfix to do TLS encryption for both incoming and outgoing mail:&amp;nbsp;&lt;/b&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;sudo postconf -e 'smtp_tls_security_level = may'&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;sudo postconf -e 'smtpd_tls_security_level = may'&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;sudo postconf -e 'smtpd_tls_auth_only = no'&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;sudo postconf -e 'smtp_tls_note_starttls_offer = yes'&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;sudo postconf -e 'smtpd_tls_key_file = /etc/ssl/private/smtpd.key'&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;sudo postconf -e 'smtpd_tls_cert_file = /etc/ssl/certs/smtpd.crt'&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;sudo postconf -e 'smtpd_tls_CAfile = /etc/ssl/certs/cacert.pem'&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;sudo postconf -e 'smtpd_tls_loglevel = 1'&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;sudo postconf -e 'smtpd_tls_received_header = yes'&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;sudo postconf -e 'smtpd_tls_session_cache_timeout = 3600s'&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;sudo postconf -e 'tls_random_source = dev:/dev/urandom'&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;sudo postconf -e 'myhostname = server1.example.com' # remember to change this to yours&lt;/span&gt;&lt;br /&gt;&lt;b&gt;&lt;span class="Apple-style-span" style="font-size: large;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;&lt;span class="Apple-style-span" style="font-size: large;"&gt;Authentication&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;The next steps are to configure Postfix to use SASL for SMTP AUTH.&lt;br /&gt;First you will need to install the libsasl2-2, sasl2-bin and libsasl2-modules from the Main repository [i.e. sudo apt-get install them all].&lt;br /&gt;&lt;br /&gt;We have to change a few things to make it work properly. Because Postfix runs chrooted in /var/spool/postfix we have change a couple paths to live in the false root. (ie. /var/run/saslauthd becomes /var/spool/postfix/var/run/saslauthd):&lt;br /&gt;&lt;br /&gt;&amp;nbsp;Note: by changing the saslauthd path other applications that use saslauthd may be affected.&lt;br /&gt;First we edit /etc/default/saslauthd in order to activate saslauthd. Remove # in front of START=yes, add the PWDIR, PARAMS, and PIDFILE lines and edit the OPTIONS line at the end:&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;# This needs to be uncommented before saslauthd will be run automatically&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;START=yes&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;PWDIR="/var/spool/postfix/var/run/saslauthd"&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;PARAMS="-m ${PWDIR}"&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;PIDFILE="${PWDIR}/saslauthd.pid"&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;# You must specify the authentication mechanisms you wish to use.&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;# This defaults to "pam" for PAM support, but may also include&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;# "shadow" or "sasldb", like this:&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;# MECHANISMS="pam shadow"&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;MECHANISMS="pam"&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;# Other options (default: -c)&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;# See the saslauthd man page for information about these options.&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;#&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;# Example for postfix users: "-c -m /var/spool/postfix/var/run/saslauthd"&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;# Note: See /usr/share/doc/sasl2-bin/README.Debian&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;#OPTIONS="-c"&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;#make sure you set the options here otherwise it ignores params above and will not work&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;OPTIONS="-c -m /var/spool/postfix/var/run/saslauthd"&lt;/span&gt;&lt;br /&gt;Note: If you prefer, you can use "shadow" instead of "pam". This will use MD5 hashed password transfer and is perfectly secure. The username and password needed to authenticate will be those of the users on the system you are using on the server.&lt;br /&gt;Next, we update the dpkg "state" of /var/spool/postfix/var/run/saslauthd. The saslauthd init script uses this setting to create the missing directory with the appropriate permissions and ownership:&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;dpkg-statoverride --force --update --add root sasl 755 /var/spool/postfix/var/run/saslauthd&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;This may report an error that "--update given" and the "/var/spool/postfix/var/run/saslauthd" directory does not exist. You can ignore this because when you start saslauthd next it will be created.&lt;br /&gt;Finally, start saslauthd:&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;sudo /etc/init.d/saslauthd start&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: large;"&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: large;"&gt;&lt;b&gt;Testing&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;To see if SMTP-AUTH and TLS work properly now run the following command:&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;telnet localhost 25&amp;nbsp;&lt;/span&gt;&lt;br /&gt;After you have established the connection to your postfix mail server type&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;ehlo localhost&amp;nbsp;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;If you see the lines&amp;nbsp;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;250-STARTTLS&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;250-AUTH&lt;/span&gt;&lt;br /&gt;among others, everything is working.&lt;br /&gt;Type quit to return to the system's shell.&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: large;"&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: large;"&gt;&lt;b&gt;Dovecot&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;Dovecot is a Mail Delivery Agent, written with security primarily in mind. It supports the major mailbox formats: mbox or Maildir. It is a simple and easy to install MDA. This guide explains how to set it up as an IMAP or POP3 server.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Installation&lt;/b&gt;&lt;br /&gt;sudo apt-get install dovecot-imapd dovecot-pop3d&lt;br /&gt;&lt;b&gt;Configuration&lt;/b&gt;&lt;br /&gt;To configure dovecot, you edit the file /etc/dovecot/dovecot.conf. There are a couple of choices which you need to make.&lt;br /&gt;&lt;br /&gt;Once you have chosen, amend the following line in the file /etc/dovecot/dovecot.conf:&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;protocols = pop3 pop3s imap imaps&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;This enables those protocols when dovecot is started. Note: if you like, you can enable all the above protocols, or you can choose to enable just one or any number of them. In addition, add the following line in the "protocol pop3" section in the /etc/dovecot/dovecot.conf:&lt;br /&gt;pop3_uidl_format = %08Xu%08Xv&lt;br /&gt;To configure Dovecot for your mailbox format use (for maildir):&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;mail_location = maildir:~/Maildir&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;or, for mbox;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;mail_location = mbox:~/mail:INBOX=/var/mail/%u&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;If you have trouble figuring out what you are using, it's most likely mbox. Maildir mails are almost always stored in ~/Maildir/ directory, which contains cur/, new/ and tmp/ subdirectories. In maildir each mail is stored in a separate file, while with the mbox format one file contains all mails in the mailbox. Files in /var/mail/ are nearly always mbox files, one for each user.&lt;br /&gt;Maildir is better overall because it is more scalable and can't get corrupted so easily. So, if you have trouble figuring out what you should be using and have a choice, choose maildir.&lt;br /&gt;&lt;b&gt;To configure Dovecot for your mailbox format use (for maildir):&amp;nbsp;&lt;/b&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;mail_location = maildir:~/Maildir&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;or, for mbox;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;mail_location = mbox:~/mail:INBOX=/var/mail/%u&lt;/span&gt;&lt;br /&gt;Note: You will also need to configure your MTA to transfer the incoming mail to this type of mailbox. (If you installed Postfix with instructions from the previous wiki, then choose mbox.)&lt;br /&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;Setting up Maildir&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;Do these steps ONLY if you want Maildir. This setup will put the Maildir in each user's home directory.&lt;br /&gt;If you are using Postfix as your MTA, then add the following line to your /etc/postfix/main.cf file:&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;home_mailbox = Maildir/&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;Edit /etc/dovecot/dovecot.conf:&amp;nbsp;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;mail_location = maildir:/home/%u/Maildir&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;It's a good idea to pre-create the Maildir for future users:&amp;nbsp;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;sudo maildirmake.dovecot /etc/skel/Maildir&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;sudo maildirmake.dovecot /etc/skel/Maildir/.Drafts&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;sudo maildirmake.dovecot /etc/skel/Maildir/.Sent&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;sudo maildirmake.dovecot /etc/skel/Maildir/.Trash&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;sudo maildirmake.dovecot /etc/skel/Maildir/.Templates&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Then, for an existing user:&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;sudo cp -r /etc/skel/Maildir /home/myuser/&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;sudo chown -R myuser:usergroup /home/myuser/Maildir&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;sudo chmod -R 700 /home/myuser/Maildir&lt;/span&gt;&lt;br /&gt;&lt;b&gt;&lt;span class="Apple-style-span" style="font-size: large;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;&lt;span class="Apple-style-span" style="font-size: large;"&gt;Test&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;Start dovecot:&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;/etc/init.d/dovecot start&lt;/span&gt;&lt;br /&gt;To check that it is running, type the command&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;ps -A | grep dovecot&lt;/span&gt;&lt;br /&gt;You should see the dovecot service running. If you have enabled imap, or pop3, you can also try to log in with the commands&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;telnet localhost pop3&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;or&amp;nbsp;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;telnet localhost imap2&lt;/span&gt;&lt;br /&gt;If you see something like the following, the installation has been successful.&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;$ telnet localhost pop3&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;Trying localhost...&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;Connected to localhost.&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;Escape character is '^]'.&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;+OK dovecot ready.&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;Or&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;$ telnet localhost 25&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;Trying 127.0.0.1...&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;Connected to localhost.localdomain (127.0.0.1).&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;Escape character is '^]'.&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;220 host.example.com ESMTP Postfix&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;EHLO testdomain.com&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;250-host.example.com&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;250-PIPELINING&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;250-SIZE 10240000&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;250-VRFY&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;250-ETRN&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;250-ENHANCEDSTATUSCODES&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;250-8BITMIME&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;MAIL FROM: &amp;lt;user@testdomain.com&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;250 2.1.0 Ok&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;RCPT TO: &amp;lt;local-user@example.com&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;250 2.1.5 Ok&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;DATA&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;354 End data with &amp;lt;CR&amp;gt;&amp;lt;LF&amp;gt;.&amp;lt;CR&amp;gt;&amp;lt;LF&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;Subject: Hello local-user&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;Hey local-user,&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;I just wanted to send some test mail to you :-)&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;.&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;250 2.0.0 Ok: queued as B95C8110064&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;QUIT&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: large;"&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: large;"&gt;&lt;b&gt;SSL&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;To configure Dovecot to use SSL, edit the file /etc/dovecot/dovecot.conf and amend the following lines (in some cases you may simply have to remove the # symbol from the beginning of the line):&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;ssl = yes&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;ssl_cert_file = /etc/ssl/certs/ssl-cert-snakeoil.pem&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;ssl_key_file = /etc/ssl/private/ssl-cert-snakeoil.key&lt;/span&gt;&lt;br /&gt;The cert and key files are created automatically by Dovecot when you install it. (The keys mentioned above are actually the ones created by Postfix, however, but are suitable for use by Dovecot as well). Please note, that these keys are not signed and will give "bad signature" errors when connecting from a client. To avoid this, you can use commercial certificates, or even better, you can use your own SSL certificates. Hopefully, a guide will appear soon on this wiki on how to do this. In the meantime, here are some good ones: this guide on the Linux howto database, and this guide on the Debian Administration website.&lt;br /&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: large;"&gt;&lt;b&gt;Accessing from Outside&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;In order to access your mail server from another computer, you'll have to configure your firewall or router to allow connections to the server on the necessary ports:&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;IMAP - 143&amp;nbsp;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;IMAPS - 993&amp;nbsp;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;POP3 - 110&amp;nbsp;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;POP3S - 995&amp;nbsp;&lt;/span&gt;&lt;br /&gt;You'll also need to uncomment following line in /etc/dovecot/dovecot.conf:&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;listen = *&lt;/span&gt;&lt;br /&gt;However, this method may cause conflicts with other servers already listening on other ports. The alternative (and probably more desirable) method, then, is to enable the specific listening ports for the protocols that are intended to be used. For example, for IMAP/IMAPS and POP3/POP3S, add to the correct protocol imap and protocol pop3 sections:&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;protocol imap {&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;listen = *:143&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;ssl_listen = *:993&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;...&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;protocol pop3 {&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;listen = *:110&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;ssl_listen = *:995&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;...&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;/span&gt;&lt;br /&gt;&lt;b&gt;&lt;span class="Apple-style-span" style="font-size: large;"&gt;Squirrelmail Configuration&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;#sudo apt-get install squirrelmail&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Squirrelmail has a very simple configuration menu. To run it, type:&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;sudo squirrelmail-configure&lt;/span&gt;&lt;br /&gt;&lt;b&gt;Apache Configuration&lt;/b&gt;&lt;br /&gt;Squirrelmail comes with a sample apache configuration file in /etc/squirrelmail/apache.conf. You can copy this file to /etc/apache2/sites-available/squirrelmail with the command:&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;sudo cp /etc/squirrelmail/apache.conf /etc/apache2/sites-available/squirrelmail&lt;/span&gt;&lt;br /&gt;then link it to the sites-enabled directory with the command:&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;sudo ln -s /etc/apache2/sites-available/squirrelmail /etc/apache2/sites-enabled/squirrelmail&lt;/span&gt;&lt;br /&gt;Reload Apache Configuration:&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;sudo /etc/init.d/apache2 force-reload&lt;/span&gt;&lt;br /&gt;If you ever wish to disable squirrelmail, you may simply delete the link in the site-enabled directory and Reload Apache's Configuration.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;&lt;span class="Apple-style-span" style="font-size: large;"&gt;Roundcube&amp;nbsp;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;You'll need apache, and mysql installed. If they are not already installed the following command will install them.&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;$sudo aptitude install apache2&lt;/span&gt;&lt;br /&gt;Run the following command to install roundcube&lt;br /&gt;$sudo aptitude install roundcube roundcube-mysql&lt;br /&gt;&lt;b&gt;Configure roundcube&amp;nbsp;&lt;/b&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;$dpkg-reconfigure roundcube-core&lt;/span&gt;&lt;br /&gt;Next create a symbolic link to apache's document root, in this case /var/www&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;$sudo ln -s /usr/share/roundcube /var/www/roundcube&amp;nbsp;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: inherit;"&gt;&lt;b&gt;Restart Apache&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;$sudo service apache2 restart&amp;nbsp;&lt;/span&gt;&lt;br /&gt;Now browse to your machine at http://localhost/roundcube&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1497521753902285776-7263483300741780921?l=jagdeepmalhi.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jagdeepmalhi.blogspot.com/feeds/7263483300741780921/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://jagdeepmalhi.blogspot.com/2011/08/configure-mail-server-in-linux-server.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1497521753902285776/posts/default/7263483300741780921'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1497521753902285776/posts/default/7263483300741780921'/><link rel='alternate' type='text/html' href='http://jagdeepmalhi.blogspot.com/2011/08/configure-mail-server-in-linux-server.html' title='Install and Configure Mail Server on Linux System'/><author><name>jagdeepsinghmalhi</name><uri>http://www.blogger.com/profile/08521786673136153319</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='26' src='http://1.bp.blogspot.com/_cKWqnDTAg-4/StdboO4vVMI/AAAAAAAAAAk/zqhdKK1K8vQ/S220/Photo%24072.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1497521753902285776.post-478348203017107019</id><published>2011-06-25T23:52:00.001+05:30</published><updated>2011-06-25T23:55:23.658+05:30</updated><category scheme='http://www.blogger.com/atom/ns#' term='diff and patch'/><title type='text'>Using patch and diff commands</title><content type='html'>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;&lt;span class="Apple-style-span" style="font-size: large;"&gt;&lt;b&gt;Creating patches with diff&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: large;"&gt;&lt;span class="Apple-style-span" style="color: #333333; font-family: Verdana, arial, sans-serif; font-size: 13px;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;Using diff is simple when you are working with single files. To create a patch for a single .&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;b&gt;diff -u file1.txt &amp;nbsp;new.txt &amp;nbsp;&amp;gt; new_file.patch&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #333333;"&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;For &amp;nbsp;the directory, use following command:&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #333333;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;b&gt;diff -rupN &amp;nbsp;directory1/ &amp;nbsp; directory2/ &amp;nbsp; &amp;gt; &amp;nbsp;dir.patch&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #333333;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #333333;"&gt;&lt;b&gt;&lt;span class="Apple-style-span" style="font-family: inherit;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;&lt;span class="Apple-style-span" style="color: #333333; font-size: large;"&gt;&lt;b&gt;Apply &amp;nbsp;patch&lt;/b&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="color: #333333; font-size: large;"&gt;&lt;b&gt;&amp;nbsp;&lt;/b&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #333333;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #333333;"&gt;&lt;span class="Apple-style-span" style="font-family: inherit;"&gt;To apply a patch to a single file, change to the directory where the file is located and call patch:&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: #333333;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;b&gt;patch &amp;nbsp;&amp;lt; dir.patch&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="font-family: Verdana, arial, sans-serif; font-size: 13px;"&gt;&lt;span class="Apple-style-span" style="color: #333333;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: #333333;"&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;you can specify the file on the command line:&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: #333333;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;b&gt;patch &amp;nbsp;file.txt &amp;lt; dir.patch&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: #333333; font-family: Times, 'Times New Roman', serif;"&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: #333333; font-family: Times, 'Times New Roman', serif;"&gt;&lt;b&gt;&lt;span class="Apple-style-span" style="font-weight: normal;"&gt;To remove a patch, use the -R flag,&amp;nbsp;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: #333333; font-family: 'Courier New', Courier, monospace;"&gt;&lt;b&gt;patch -R file.txt &amp;lt; file.patch&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: #333333;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="font-family: 'Times New Roman'; font-size: medium;"&gt;&lt;span class="Apple-style-span" style="color: #333333;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1497521753902285776-478348203017107019?l=jagdeepmalhi.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jagdeepmalhi.blogspot.com/feeds/478348203017107019/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://jagdeepmalhi.blogspot.com/2011/06/using-patch-and-diff-commands.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1497521753902285776/posts/default/478348203017107019'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1497521753902285776/posts/default/478348203017107019'/><link rel='alternate' type='text/html' href='http://jagdeepmalhi.blogspot.com/2011/06/using-patch-and-diff-commands.html' title='Using patch and diff commands'/><author><name>jagdeepsinghmalhi</name><uri>http://www.blogger.com/profile/08521786673136153319</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='26' src='http://1.bp.blogspot.com/_cKWqnDTAg-4/StdboO4vVMI/AAAAAAAAAAk/zqhdKK1K8vQ/S220/Photo%24072.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1497521753902285776.post-2486476127031341299</id><published>2011-06-09T23:11:00.001+05:30</published><updated>2011-06-09T23:24:03.853+05:30</updated><category scheme='http://www.blogger.com/atom/ns#' term='Network manager'/><title type='text'>Network Manager Error : Device not managed (ubuntu)</title><content type='html'>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;&lt;span class="Apple-style-span" style="font-size: 12px;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;div class="vbclean_msgtext" id="post_message_6975215" style="color: black; font-family: Verdana, Arial, Tahoma;"&gt;I am facing the problem with Network Manager shows &amp;nbsp;error, with Wired and Wireless connection. When I click on &amp;nbsp;tetwork connection, It show "device not managed".&lt;/div&gt;&lt;div class="vbclean_msgtext" id="post_message_6975215" style="color: black; font-family: Verdana, Arial, Tahoma;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="vbclean_msgtext" id="post_message_6975215" style="color: black; font-family: Verdana, Arial, Tahoma;"&gt;&lt;b&gt;Problem Solve :&lt;/b&gt;&lt;/div&gt;&lt;div class="vbclean_msgtext" id="post_message_6975215" style="color: black; font-family: Verdana, Arial, Tahoma;"&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;&lt;div class="vbclean_msgtext" id="post_message_6975215" style="color: black;"&gt;&lt;span style="font-family: Verdana, Arial, Tahoma;"&gt;&amp;gt;&lt;/span&gt;&lt;b style="font-family: Verdana, Arial, Tahoma;"&gt;&amp;nbsp;&lt;/b&gt;&lt;span class="Apple-style-span" style="font-family: Verdana, Arial, Tahoma;"&gt;First run command on terminal to see the connection status &lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;i&gt;&amp;nbsp;sudo &amp;nbsp;lshw -C Network&amp;nbsp;&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="vbclean_msgtext" id="post_message_6975215" style="color: black;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: inherit;"&gt;This show ouput like :&lt;/span&gt;&lt;/div&gt;&lt;div class="vbclean_msgtext" id="post_message_6975215" style="color: black;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="vbclean_msgtext" id="post_message_6975215"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;sudo lshw -C network&lt;/span&gt;&lt;/div&gt;&lt;div class="vbclean_msgtext" id="post_message_6975215"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;[sudo] password for jagdeep:&amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;div class="vbclean_msgtext" id="post_message_6975215"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp; *-network DISABLED &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;div class="vbclean_msgtext" id="post_message_6975215"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;description: Wireless interface&lt;/span&gt;&lt;/div&gt;&lt;div class="vbclean_msgtext" id="post_message_6975215"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;product: Centrino Wireless-N 1000&lt;/span&gt;&lt;/div&gt;&lt;div class="vbclean_msgtext" id="post_message_6975215"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;vendor: Intel Corporation&lt;/span&gt;&lt;/div&gt;&lt;div class="vbclean_msgtext" id="post_message_6975215"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;physical id: 0&lt;/span&gt;&lt;/div&gt;&lt;div class="vbclean_msgtext" id="post_message_6975215"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;bus info: pci@0000:03:00.0&lt;/span&gt;&lt;/div&gt;&lt;div class="vbclean_msgtext" id="post_message_6975215"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;logical name: wlan0&lt;/span&gt;&lt;/div&gt;&lt;div class="vbclean_msgtext" id="post_message_6975215"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;version: 00&lt;/span&gt;&lt;/div&gt;&lt;div class="vbclean_msgtext" id="post_message_6975215"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;serial: 8c:a9:82:5e:e4:e2&lt;/span&gt;&lt;/div&gt;&lt;div class="vbclean_msgtext" id="post_message_6975215"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;width: 64 bits&lt;/span&gt;&lt;/div&gt;&lt;div class="vbclean_msgtext" id="post_message_6975215"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;clock: 33MHz&lt;/span&gt;&lt;/div&gt;&lt;div class="vbclean_msgtext" id="post_message_6975215"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;capabilities: pm msi pciexpress bus_master cap_list ethernet physical wireless&lt;/span&gt;&lt;/div&gt;&lt;div class="vbclean_msgtext" id="post_message_6975215"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;configuration: broadcast=yes driver=iwlagn driverversion=2.6.38-8-generic firmware=128.50.3.1 build 13488 ip=192.168.1.34 latency=0 link=yes multicast=yes wireless=IEEE 802.11bgn&lt;/span&gt;&lt;/div&gt;&lt;div class="vbclean_msgtext" id="post_message_6975215"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;a name='more'&gt;&lt;/a&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;resources: irq:41 memory:f0500000-f0501fff&lt;/span&gt;&lt;/div&gt;&lt;div class="vbclean_msgtext" id="post_message_6975215"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp; *-network&amp;nbsp;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;DISABLED&lt;/span&gt;&lt;/div&gt;&lt;div class="vbclean_msgtext" id="post_message_6975215"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;description: Ethernet interface&lt;/span&gt;&lt;/div&gt;&lt;div class="vbclean_msgtext" id="post_message_6975215"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;product: AR8152 v1.1 Fast Ethernet&lt;/span&gt;&lt;/div&gt;&lt;div class="vbclean_msgtext" id="post_message_6975215"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;vendor: Atheros Communications&lt;/span&gt;&lt;/div&gt;&lt;div class="vbclean_msgtext" id="post_message_6975215"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;physical id: 0&lt;/span&gt;&lt;/div&gt;&lt;div class="vbclean_msgtext" id="post_message_6975215"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;bus info: pci@0000:04:00.0&lt;/span&gt;&lt;/div&gt;&lt;div class="vbclean_msgtext" id="post_message_6975215"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;logical name: eth0&lt;/span&gt;&lt;/div&gt;&lt;div class="vbclean_msgtext" id="post_message_6975215"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;version: c1&lt;/span&gt;&lt;/div&gt;&lt;div class="vbclean_msgtext" id="post_message_6975215"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;serial: 14:fe:b5:9a:33:ba&lt;/span&gt;&lt;/div&gt;&lt;div class="vbclean_msgtext" id="post_message_6975215"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;capacity: 100Mbit/s&lt;/span&gt;&lt;/div&gt;&lt;div class="vbclean_msgtext" id="post_message_6975215"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;width: 64 bits&lt;/span&gt;&lt;/div&gt;&lt;div class="vbclean_msgtext" id="post_message_6975215"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;clock: 33MHz&lt;/span&gt;&lt;/div&gt;&lt;div class="vbclean_msgtext" id="post_message_6975215"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;capabilities: pm msi pciexpress vpd bus_master cap_list ethernet physical tp 10bt 10bt-fd 100bt 100bt-fd autonegotiation&lt;/span&gt;&lt;/div&gt;&lt;div class="vbclean_msgtext" id="post_message_6975215"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;configuration: autonegotiation=on broadcast=yes driver=atl1c driverversion=1.0.1.0-NAPI firmware=N/A latency=0 link=no multicast=yes port=twisted pair&lt;/span&gt;&lt;/div&gt;&lt;div class="vbclean_msgtext" id="post_message_6975215"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;resources: irq:44 memory:f0400000-f043ffff ioport:2000(size=128)&lt;/span&gt;&lt;/div&gt;&lt;div class="vbclean_msgtext" id="post_message_6975215" style="color: black;"&gt;&lt;/div&gt;&lt;div class="vbclean_msgtext" id="post_message_6975215"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: inherit;"&gt; If it Show connection is DISABLED than you need to edit&amp;nbsp;following&amp;nbsp;file&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&lt;i&gt;/&lt;/i&gt;&lt;/span&gt;&lt;span style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;i&gt;etc/NetworkManager/NetworkManager.conf or&amp;nbsp;/etc/NetworkManager/nm-system-settings.conf&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="vbclean_msgtext" id="post_message_6975215"&gt;&lt;span style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="vbclean_msgtext" id="post_message_6975215"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;&lt;i&gt;Code :&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="vbclean_msgtext" id="post_message_6975215"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;&lt;i&gt;[main]&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="vbclean_msgtext" id="post_message_6975215"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;&lt;i&gt;plugins=ifupdown, keyfile&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="vbclean_msgtext" id="post_message_6975215"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="vbclean_msgtext" id="post_message_6975215"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;&lt;i&gt;[ifupdown]&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="vbclean_msgtext" id="post_message_6975215"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;&lt;i&gt;managed=false&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="vbclean_msgtext" id="post_message_6975215"&gt;&lt;span class="Apple-style-span" style="font-family: Verdana, Arial, Tahoma; font-size: 12px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="vbclean_msgtext" id="post_message_6975215"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;i&gt;&lt;/i&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: Verdana, Arial, Tahoma;"&gt;&amp;gt; Changing&amp;nbsp;&lt;i&gt;managed=false&lt;/i&gt;&amp;nbsp;to&amp;nbsp;&lt;i&gt;managed=true&lt;/i&gt;&amp;nbsp;if &amp;nbsp;You want NM to manage&lt;/span&gt;&lt;/div&gt;&lt;div class="vbclean_msgtext" id="post_message_6975215"&gt;&lt;span class="Apple-style-span" style="font-family: Verdana, Arial, Tahoma;"&gt;&amp;gt;&amp;nbsp;&lt;/span&gt;&lt;span class="Apple-style-span" style="color: #333333; font-family: Arial, Helvetica; line-height: 21px;"&gt;Now back in the terminal type&amp;nbsp;&lt;span style="font-weight: bold; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;sudo killall nm-system-settings or&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="color: #333333; font-family: Arial, Helvetica; font-size: 12px; line-height: 21px;"&gt;&amp;nbsp;&lt;span style="font-weight: bold; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;sudo killall NetworkManger.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="vbclean_msgtext" id="post_message_6975215"&gt;&lt;span class="Apple-style-span" style="color: #333333; font-family: Arial, Helvetica; font-size: 12px; line-height: 21px;"&gt;&lt;span style="font-weight: bold; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="vbclean_msgtext" id="post_message_6975215"&gt;&lt;span class="Apple-style-span" style="color: #333333; font-family: Arial, Helvetica; line-height: 21px;"&gt;&lt;span style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;It works.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="vbclean_msgtext" id="post_message_6975215"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="vbclean_msgtext" id="post_message_6975215"&gt;&lt;span class="Apple-style-span" style="font-family: inherit;"&gt;&lt;b&gt;Some Basic Network Commands&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="vbclean_msgtext" id="post_message_6975215"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;i&gt;&lt;/i&gt;&lt;/span&gt;&lt;br /&gt;&lt;div class="vbclean_msgtext" id="post_message_6975215"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;i&gt;&amp;nbsp;$sudo /etc/init.d/networking restart&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="vbclean_msgtext" id="post_message_6975215"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;i&gt;&amp;nbsp;$ping google.com&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="vbclean_msgtext" id="post_message_6975215"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;i&gt;&amp;nbsp;$plog&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="vbclean_msgtext" id="post_message_6975215"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;i&gt;&amp;nbsp;$ifconfig&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="vbclean_msgtext" id="post_message_6975215"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;i&gt;&amp;nbsp;$&lt;span class="Apple-style-span" style="font-style: normal;"&gt;&lt;i&gt;&lt;/i&gt;&lt;/span&gt;&lt;/i&gt;&lt;/span&gt;&lt;br /&gt;&lt;div class="vbclean_msgtext" id="post_message_6975215" style="display: inline !important;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;i&gt;&lt;span class="Apple-style-span" style="font-style: normal;"&gt;&lt;i&gt;sudo pppoeconf (For setting Dail up Connection with username and password)&lt;/i&gt;&lt;/span&gt;&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="vbclean_msgtext" id="post_message_6975215"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;i&gt;&amp;nbsp;$&lt;span class="Apple-style-span" style="font-style: normal;"&gt;&lt;i&gt;&lt;/i&gt;&lt;/span&gt;&lt;/i&gt;&lt;/span&gt;&lt;br /&gt;&lt;div class="vbclean_msgtext" id="post_message_6975215" style="display: inline !important;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;i&gt;&lt;span class="Apple-style-span" style="font-style: normal;"&gt;&lt;i&gt;lsusb&lt;/i&gt;&lt;/span&gt;&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="vbclean_msgtext" id="post_message_6975215"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;i&gt;&amp;nbsp;$lspci&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="vbclean_msgtext" id="post_message_6975215"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;i&gt;&amp;nbsp;$lsmod&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="vbclean_msgtext" id="post_message_6975215"&gt;&lt;div class="vbclean_msgtext" id="post_message_6975215"&gt;&lt;br /&gt;&lt;div class="vbclean_msgtext" id="post_message_6975215" style="display: inline !important;"&gt;&lt;div class="vbclean_msgtext" id="post_message_6975215" style="display: inline !important;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;i&gt;&lt;span class="Apple-style-span" style="font-style: normal;"&gt;&lt;i&gt;$iwlist&lt;/i&gt;&lt;/span&gt;&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="vbclean_msgtext" id="post_message_6975215"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;i&gt;&amp;nbsp;$sudo iwlist eth0 scan&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="vbclean_msgtext" id="post_message_6975215"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;i&gt;&amp;nbsp;$sudo lshw -C network&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="vbclean_msgtext" id="post_message_6975215"&gt;&lt;div class="vbclean_msgtext" id="post_message_6975215"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;i&gt;&amp;nbsp;$rfkill list all&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="vbclean_msgtext" id="post_message_6975215"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;i&gt;&amp;nbsp;$rfkill unblock all&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="vbclean_msgtext" id="post_message_6975215"&gt;&lt;div class="vbclean_msgtext" id="post_message_6975215"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;i&gt;&amp;nbsp;$sudo /etc/init.d/networking restart&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style="color: black;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="vbclean_msgtext" id="post_message_6975215" style="color: black;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="vbclean_msgtext" id="post_message_6975215" style="color: black;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1497521753902285776-2486476127031341299?l=jagdeepmalhi.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jagdeepmalhi.blogspot.com/feeds/2486476127031341299/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://jagdeepmalhi.blogspot.com/2011/06/network-manager-error-device-not.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1497521753902285776/posts/default/2486476127031341299'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1497521753902285776/posts/default/2486476127031341299'/><link rel='alternate' type='text/html' href='http://jagdeepmalhi.blogspot.com/2011/06/network-manager-error-device-not.html' title='Network Manager Error : Device not managed (ubuntu)'/><author><name>jagdeepsinghmalhi</name><uri>http://www.blogger.com/profile/08521786673136153319</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='26' src='http://1.bp.blogspot.com/_cKWqnDTAg-4/StdboO4vVMI/AAAAAAAAAAk/zqhdKK1K8vQ/S220/Photo%24072.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1497521753902285776.post-3001863826658330459</id><published>2011-02-15T22:52:00.003+05:30</published><updated>2011-06-09T23:24:51.264+05:30</updated><title type='text'>PHP/MySql : Store file path in database, file in folder</title><content type='html'>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;&lt;b&gt;Create a file : form.html&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;form action=addmembers.php method=post enctype="multipart/form-data"&amp;gt;&lt;br /&gt;&amp;lt;table border="0" cellspacing="0" align=center cellpadding="3" bordercolor="#cccccc"&amp;gt;&lt;br /&gt;&amp;lt;tr&amp;gt;&lt;br /&gt;&amp;lt;td&amp;gt;File:&amp;lt;/td&amp;gt;&lt;br /&gt;&amp;lt;td&amp;gt;&amp;lt;input type="file" name="filep" size=45&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;&amp;lt;tr&amp;gt;&lt;br /&gt;&amp;lt;td colspan=2&amp;gt;&amp;lt;p align=center&amp;gt;&lt;br /&gt;&amp;lt;input type=submit name=action value="Load"&amp;gt;&lt;br /&gt;&amp;lt;/td&amp;gt;&lt;br /&gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;&amp;lt;/table&amp;gt;&lt;br /&gt;&amp;lt;/form&amp;gt;&lt;br /&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;Create another file : addmembers.php&lt;/b&gt;&lt;br /&gt;&amp;lt;?&lt;br /&gt;&lt;br /&gt;if ($_POST["action"] == "Load")&lt;br /&gt;{&lt;br /&gt;$folder = "images/";&lt;br /&gt;&lt;br /&gt;&lt;a name='more'&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;move_uploaded_file($_FILES["filep"]["tmp_name"] , "$folder".$_FILES["filep"]["name"]);&lt;br /&gt;&lt;br /&gt;echo "&amp;lt;p align=center&amp;gt;File ".$_FILES["filep"]["name"]."loaded...";&lt;br /&gt;&lt;br /&gt;$result = mysql_connect("localhost", "****", "****") or die ("Could not save image name Error: " . mysql_error());&lt;br /&gt;mysql_select_db("test") or die("Could not select database");&lt;br /&gt;mysql_query("INSERT into picture (URL) VALUES('".$_FILES['filep']['name']."')");&lt;br /&gt;&lt;br /&gt;if($result) { echo "Image name saved into database"; }&lt;br /&gt;else {&lt;br /&gt;&lt;br /&gt;//Gives and error if its not&lt;br /&gt;echo "Sorry, there was a problem uploading your file.";&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;?&amp;gt;&lt;br /&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;For Display the file use code :&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;?&lt;br /&gt;//Retrieves data from MySQL&lt;br /&gt;mysql_connect("localhost", "****", "*****") or die ("Could not save image name Error: " . mysql_error());&lt;br /&gt;mysql_select_db("test") or die("Could not select database");&lt;br /&gt;$data = mysql_query("SELECT `URL` FROM picture ") or&lt;br /&gt;die(mysql_error());&lt;br /&gt;//Puts it into an array&lt;br /&gt;$file_path = 'http://localhost/test/images/';&lt;br /&gt;&lt;br /&gt;while($row = mysql_fetch_assoc( $data ))&lt;br /&gt;{//Outputs the image and other data&lt;br /&gt;$src=$file_path.$row['URL'];&lt;br /&gt;echo "&amp;lt;img src=".$src."&amp;gt; &amp;nbsp;&amp;lt;br&amp;gt;";&lt;br /&gt;}&lt;br /&gt;?&amp;gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1497521753902285776-3001863826658330459?l=jagdeepmalhi.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jagdeepmalhi.blogspot.com/feeds/3001863826658330459/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://jagdeepmalhi.blogspot.com/2011/02/phpmysql-store-file-path-in-database.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1497521753902285776/posts/default/3001863826658330459'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1497521753902285776/posts/default/3001863826658330459'/><link rel='alternate' type='text/html' href='http://jagdeepmalhi.blogspot.com/2011/02/phpmysql-store-file-path-in-database.html' title='PHP/MySql : Store file path in database, file in folder'/><author><name>jagdeepsinghmalhi</name><uri>http://www.blogger.com/profile/08521786673136153319</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='26' src='http://1.bp.blogspot.com/_cKWqnDTAg-4/StdboO4vVMI/AAAAAAAAAAk/zqhdKK1K8vQ/S220/Photo%24072.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1497521753902285776.post-9059776161588814106</id><published>2010-12-14T23:10:00.003+05:30</published><updated>2010-12-14T23:14:29.535+05:30</updated><title type='text'>Comparison of Oracle, MySQL and Postgres DBMS</title><content type='html'>&lt;title&gt;&lt;/title&gt; 	 	&lt;style type="text/css"&gt;	&lt;!--		@page { margin: 2cm }		P { margin-bottom: 0.21cm }		H3 { margin-bottom: 0.21cm }		TD P { margin-bottom: 0cm }		TH P { margin-bottom: 0cm }	--&gt;	&lt;/style&gt;   &lt;br /&gt;&lt;div style="margin-bottom: 0cm;"&gt;&lt;title&gt;&lt;/title&gt; 	 	&lt;style type="text/css"&gt;	&lt;!--		@page { margin: 2cm }		P { margin-bottom: 0.21cm }	--&gt;	&lt;/style&gt;   &lt;/div&gt;&lt;div style="margin-bottom: 0cm;"&gt;&lt;span style="font-family: 'Times New Roman', serif;"&gt;Comparison are given below with include all the basic concept :-&lt;/span&gt;&lt;/div&gt;&lt;table border="1" cellpadding="2" cellspacing="0"&gt;	&lt;colgroup&gt;&lt;col width="53*"&gt;&lt;/col&gt; 	&lt;col width="92*"&gt;&lt;/col&gt; 	&lt;col width="44*"&gt;&lt;/col&gt; 	&lt;col width="36*"&gt;&lt;/col&gt; 	&lt;col width="31*"&gt;&lt;/col&gt; 	&lt;/colgroup&gt;&lt;tbody&gt;&lt;tr&gt; 		&lt;th rowspan="2" width="21%"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;Category&lt;/span&gt;&lt;/th&gt; 		&lt;th rowspan="2" width="36%"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;Problem&lt;/span&gt;&lt;/th&gt; 		&lt;th colspan="3" width="43%"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;Assessment&lt;/span&gt;&lt;/th&gt; 	&lt;/tr&gt;&lt;tr&gt; 		&lt;th width="17%"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;MySQL&lt;/span&gt;&lt;/th&gt; 		&lt;th width="14%"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;Oracle8&lt;/span&gt;&lt;/th&gt; 		&lt;th width="12%"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;Postgres&lt;/span&gt;&lt;/th&gt; 	&lt;/tr&gt;&lt;tr&gt; 		&lt;td rowspan="6" width="21%"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;Elementary features&lt;/span&gt;&lt;/td&gt; 		&lt;td width="36%"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;Basic data types&lt;/span&gt;&lt;/td&gt; 		&lt;td width="17%"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;B&lt;/span&gt;&lt;/td&gt; 		&lt;td width="14%"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;C&lt;/span&gt;&lt;/td&gt; 		&lt;td width="12%"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;A&lt;/span&gt;&lt;/td&gt; 	&lt;/tr&gt;&lt;tr&gt; 		&lt;td width="36%"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;SQL&lt;/span&gt;&lt;/td&gt; 		&lt;td width="17%"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;C&lt;/span&gt;&lt;/td&gt; 		&lt;td width="14%"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;B&lt;/span&gt;&lt;/td&gt; 		&lt;td width="12%"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;B&lt;/span&gt;&lt;/td&gt; 	&lt;/tr&gt;&lt;tr&gt; 		&lt;td width="36%"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;Declarative constraints&lt;/span&gt;&lt;/td&gt; 		&lt;td width="17%"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;C&lt;/span&gt;&lt;/td&gt; 		&lt;td width="14%"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;A&lt;/span&gt;&lt;/td&gt; 		&lt;td width="12%"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;A&lt;/span&gt;&lt;/td&gt; 	&lt;/tr&gt;&lt;tr&gt; 		&lt;td width="36%"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;Programming abstractions&lt;/span&gt;&lt;/td&gt; 		&lt;td width="17%"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;D&lt;/span&gt;&lt;/td&gt; 		&lt;td width="14%"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;A&lt;/span&gt;&lt;/td&gt; 		&lt;td width="12%"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;C&lt;/span&gt;&lt;/td&gt; 	&lt;/tr&gt;&lt;tr&gt; 		&lt;td width="36%"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;Generation of ids&lt;/span&gt;&lt;/td&gt; 		&lt;td width="17%"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;C&lt;/span&gt;&lt;/td&gt; 		&lt;td width="14%"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;A&lt;/span&gt;&lt;/td&gt; 		&lt;td width="12%"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;A&lt;/span&gt;&lt;/td&gt; 	&lt;/tr&gt;&lt;tr&gt; 		&lt;td width="36%"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;National chars&lt;/span&gt;&lt;/td&gt; 		&lt;td width="17%"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;B&lt;/span&gt;&lt;/td&gt; 		&lt;td width="14%"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;A&lt;/span&gt;&lt;/td&gt; 		&lt;td width="12%"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;B&lt;/span&gt;&lt;/td&gt; 	&lt;/tr&gt;&lt;tr&gt; 		&lt;td rowspan="3" width="21%"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;Transactions&lt;/span&gt;&lt;/td&gt; 		&lt;td width="36%"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;Transactions&lt;/span&gt;&lt;/td&gt; 		&lt;td width="17%"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;D&lt;/span&gt;&lt;/td&gt; 		&lt;td width="14%"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;A&lt;/span&gt;&lt;/td&gt; 		&lt;td width="12%"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;A&lt;/span&gt;&lt;/td&gt; 	&lt;/tr&gt;&lt;tr&gt; 		&lt;td width="36%"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;Locks&lt;/span&gt;&lt;/td&gt; 		&lt;td width="17%"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;D&lt;/span&gt;&lt;/td&gt; 		&lt;td width="14%"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;A&lt;/span&gt;&lt;/td&gt; 		&lt;td width="12%"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;A&lt;/span&gt;&lt;/td&gt; 	&lt;/tr&gt;&lt;tr&gt; 		&lt;td width="36%"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;Multiuser access&lt;/span&gt;&lt;/td&gt; 		&lt;td width="17%"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;C&lt;/span&gt;&lt;/td&gt; 		&lt;td width="14%"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;A&lt;/span&gt;&lt;/td&gt; 		&lt;td width="12%"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;C&lt;/span&gt;&lt;/td&gt; 	&lt;/tr&gt;&lt;tr&gt; 		&lt;td width="21%"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;Programming in DB&lt;/span&gt;&lt;/td&gt; 		&lt;td width="36%"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;a name='more'&gt;&lt;/a&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;Stored procedures and triggers&lt;/span&gt;&lt;/td&gt; 		&lt;td width="17%"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;D&lt;/span&gt;&lt;/td&gt; 		&lt;td width="14%"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;A&lt;/span&gt;&lt;/td&gt; 		&lt;td width="12%"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;A&lt;/span&gt;&lt;/td&gt; 	&lt;/tr&gt;&lt;tr&gt; 		&lt;td rowspan="3" width="21%"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;Administration&lt;/span&gt;&lt;/td&gt; 		&lt;td width="36%"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;Access control&lt;/span&gt;&lt;/td&gt; 		&lt;td width="17%"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;A&lt;/span&gt;&lt;/td&gt; 		&lt;td width="14%"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;A&lt;/span&gt;&lt;/td&gt; 		&lt;td width="12%"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;B&lt;/span&gt;&lt;/td&gt; 	&lt;/tr&gt;&lt;tr&gt; 		&lt;td width="36%"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;Backup&lt;/span&gt;&lt;/td&gt; 		&lt;td width="17%"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;C&lt;/span&gt;&lt;/td&gt; 		&lt;td width="14%"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;A&lt;/span&gt;&lt;/td&gt; 		&lt;td width="12%"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;C&lt;/span&gt;&lt;/td&gt; 	&lt;/tr&gt;&lt;tr&gt; 		&lt;td width="36%"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;Data migration&lt;/span&gt;&lt;/td&gt; 		&lt;td width="17%"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;A&lt;/span&gt;&lt;/td&gt; 		&lt;td width="14%"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;B&lt;/span&gt;&lt;/td&gt; 		&lt;td width="12%"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;A&lt;/span&gt;&lt;/td&gt; 	&lt;/tr&gt;&lt;tr&gt; 		&lt;td rowspan="2" width="21%"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;Portability and scalability&lt;/span&gt;&lt;/td&gt; 		&lt;td width="36%"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;Portability&lt;/span&gt;&lt;/td&gt; 		&lt;td width="17%"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;B&lt;/span&gt;&lt;/td&gt; 		&lt;td width="14%"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;A&lt;/span&gt;&lt;/td&gt; 		&lt;td width="12%"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;B&lt;/span&gt;&lt;/td&gt; 	&lt;/tr&gt;&lt;tr&gt; 		&lt;td width="36%"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;Scalability&lt;/span&gt;&lt;/td&gt; 		&lt;td width="17%"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;B&lt;/span&gt;&lt;/td&gt; 		&lt;td width="14%"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;A&lt;/span&gt;&lt;/td&gt; 		&lt;td width="12%"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;C&lt;/span&gt;&lt;/td&gt; 	&lt;/tr&gt;&lt;tr&gt; 		&lt;td rowspan="6" width="21%"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;Performance and VLDB&lt;/span&gt;&lt;/td&gt; 		&lt;td width="36%"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;Query optimization&lt;/span&gt;&lt;/td&gt; 		&lt;td width="17%"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;B&lt;/span&gt;&lt;/td&gt; 		&lt;td width="14%"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;A&lt;/span&gt;&lt;/td&gt; 		&lt;td width="12%"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;B&lt;/span&gt;&lt;/td&gt; 	&lt;/tr&gt;&lt;tr&gt; 		&lt;td width="36%"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;Structures supporting optimization&lt;/span&gt;&lt;/td&gt; 		&lt;td width="17%"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;D&lt;/span&gt;&lt;/td&gt; 		&lt;td width="14%"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;A&lt;/span&gt;&lt;/td&gt; 		&lt;td width="12%"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;B&lt;/span&gt;&lt;/td&gt; 	&lt;/tr&gt;&lt;tr&gt; 		&lt;td width="36%"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;Support for OLAP&lt;/span&gt;&lt;/td&gt; 		&lt;td width="17%"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;D&lt;/span&gt;&lt;/td&gt; 		&lt;td width="14%"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;A&lt;/span&gt;&lt;/td&gt; 		&lt;td width="12%"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;D&lt;/span&gt;&lt;/td&gt; 	&lt;/tr&gt;&lt;tr&gt; 		&lt;td width="36%"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;Allocation of the disk space&lt;/span&gt;&lt;/td&gt; 		&lt;td width="17%"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;C&lt;/span&gt;&lt;/td&gt; 		&lt;td width="14%"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;A&lt;/span&gt;&lt;/td&gt; 		&lt;td width="12%"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;C&lt;/span&gt;&lt;/td&gt; 	&lt;/tr&gt;&lt;tr&gt; 		&lt;td width="36%"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;Size limits&lt;/span&gt;&lt;/td&gt; 		&lt;td width="17%"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;B&lt;/span&gt;&lt;/td&gt; 		&lt;td width="14%"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;A&lt;/span&gt;&lt;/td&gt; 		&lt;td width="12%"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;C&lt;/span&gt;&lt;/td&gt; 	&lt;/tr&gt;&lt;tr&gt; 		&lt;td width="36%"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;VLDB implementations&lt;/span&gt;&lt;/td&gt; 		&lt;td width="17%"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;D&lt;/span&gt;&lt;/td&gt; 		&lt;td width="14%"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;A&lt;/span&gt;&lt;/td&gt; 		&lt;td width="12%"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;B&lt;/span&gt;&lt;/td&gt; 	&lt;/tr&gt;&lt;tr&gt; 		&lt;td rowspan="2" width="21%"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;Distributed databases&lt;/span&gt;&lt;/td&gt; 		&lt;td width="36%"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;Access to multiple databases&lt;/span&gt;&lt;/td&gt; 		&lt;td width="17%"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;C&lt;/span&gt;&lt;/td&gt; 		&lt;td width="14%"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;A&lt;/span&gt;&lt;/td&gt; 		&lt;td width="12%"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;C&lt;/span&gt;&lt;/td&gt; 	&lt;/tr&gt;&lt;tr&gt; 		&lt;td width="36%"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;Heterogeneous systems support&lt;/span&gt;&lt;/td&gt; 		&lt;td width="17%"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;D&lt;/span&gt;&lt;/td&gt; 		&lt;td width="14%"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;B&lt;/span&gt;&lt;/td&gt; 		&lt;td width="12%"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;D&lt;/span&gt;&lt;/td&gt; 	&lt;/tr&gt;&lt;tr&gt; 		&lt;td rowspan="3" width="21%"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;Special data types&lt;/span&gt;&lt;/td&gt; 		&lt;td width="36%"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;Large objects&lt;/span&gt;&lt;/td&gt; 		&lt;td width="17%"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;B&lt;/span&gt;&lt;/td&gt; 		&lt;td width="14%"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;A&lt;/span&gt;&lt;/td&gt; 		&lt;td width="12%"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;C&lt;/span&gt;&lt;/td&gt; 	&lt;/tr&gt;&lt;tr&gt; 		&lt;td width="36%"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;Post-relational extensions&lt;/span&gt;&lt;/td&gt; 		&lt;td width="17%"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;D&lt;/span&gt;&lt;/td&gt; 		&lt;td width="14%"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;A&lt;/span&gt;&lt;/td&gt; 		&lt;td width="12%"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;B&lt;/span&gt;&lt;/td&gt; 	&lt;/tr&gt;&lt;tr&gt; 		&lt;td width="36%"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;Support for special data types&lt;/span&gt;&lt;/td&gt; 		&lt;td width="17%"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;D&lt;/span&gt;&lt;/td&gt; 		&lt;td width="14%"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;A&lt;/span&gt;&lt;/td&gt; 		&lt;td width="12%"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;C&lt;/span&gt;&lt;/td&gt; 	&lt;/tr&gt;&lt;tr&gt; 		&lt;td rowspan="6" width="21%"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;Application development and interfaces&lt;/span&gt;&lt;/td&gt; 		&lt;td width="36%"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;Embedded SQL&lt;/span&gt;&lt;/td&gt; 		&lt;td width="17%"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;D&lt;/span&gt;&lt;/td&gt; 		&lt;td width="14%"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;A&lt;/span&gt;&lt;/td&gt; 		&lt;td width="12%"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;B&lt;/span&gt;&lt;/td&gt; 	&lt;/tr&gt;&lt;tr&gt; 		&lt;td width="36%"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;Standard interfaces&lt;/span&gt;&lt;/td&gt; 		&lt;td width="17%"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;B&lt;/span&gt;&lt;/td&gt; 		&lt;td width="14%"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;A&lt;/span&gt;&lt;/td&gt; 		&lt;td width="12%"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;B&lt;/span&gt;&lt;/td&gt; 	&lt;/tr&gt;&lt;tr&gt; 		&lt;td width="36%"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;Additional interfaces&lt;/span&gt;&lt;/td&gt; 		&lt;td width="17%"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;A&lt;/span&gt;&lt;/td&gt; 		&lt;td width="14%"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;A&lt;/span&gt;&lt;/td&gt; 		&lt;td width="12%"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;A&lt;/span&gt;&lt;/td&gt; 	&lt;/tr&gt;&lt;tr&gt; 		&lt;td width="36%"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;Web technology&lt;/span&gt;&lt;/td&gt; 		&lt;td width="17%"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;B&lt;/span&gt;&lt;/td&gt; 		&lt;td width="14%"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;A&lt;/span&gt;&lt;/td&gt; 		&lt;td width="12%"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;B&lt;/span&gt;&lt;/td&gt; 	&lt;/tr&gt;&lt;tr&gt; 		&lt;td width="36%"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;XML&lt;/span&gt;&lt;/td&gt; 		&lt;td width="17%"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;D&lt;/span&gt;&lt;/td&gt; 		&lt;td width="14%"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;A&lt;/span&gt;&lt;/td&gt; 		&lt;td width="12%"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;D&lt;/span&gt;&lt;/td&gt; 	&lt;/tr&gt;&lt;tr&gt; 		&lt;td width="36%"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;CASE&lt;/span&gt;&lt;/td&gt; 		&lt;td width="17%"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;D&lt;/span&gt;&lt;/td&gt; 		&lt;td width="14%"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;A&lt;/span&gt;&lt;/td&gt; 		&lt;td width="12%"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;D&lt;/span&gt;&lt;/td&gt; 	&lt;/tr&gt;&lt;tr&gt; 		&lt;td width="21%"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;Reliability&lt;/span&gt;&lt;/td&gt; 		&lt;td width="36%"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;Recovery&lt;/span&gt;&lt;/td&gt; 		&lt;td width="17%"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;C&lt;/span&gt;&lt;/td&gt; 		&lt;td width="14%"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;A&lt;/span&gt;&lt;/td&gt; 		&lt;td width="12%"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;C&lt;/span&gt;&lt;/td&gt; 	&lt;/tr&gt;&lt;tr&gt; 		&lt;td rowspan="3" width="21%"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;Commercial issues&lt;/span&gt;&lt;/td&gt; 		&lt;td width="36%"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;Prices&lt;/span&gt;&lt;/td&gt; 		&lt;td width="17%"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;A&lt;/span&gt;&lt;/td&gt; 		&lt;td width="14%"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;D&lt;/span&gt;&lt;/td&gt; 		&lt;td width="12%"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;A&lt;/span&gt;&lt;/td&gt; 	&lt;/tr&gt;&lt;tr&gt; 		&lt;td width="36%"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;Technical support&lt;/span&gt;&lt;/td&gt; 		&lt;td width="17%"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;C&lt;/span&gt;&lt;/td&gt; 		&lt;td width="14%"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;B&lt;/span&gt;&lt;/td&gt; 		&lt;td width="12%"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;D&lt;/span&gt;&lt;/td&gt; 	&lt;/tr&gt;&lt;tr&gt; 		&lt;td width="36%"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;Position on the market&lt;/span&gt;&lt;/td&gt; 		&lt;td width="17%"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;D&lt;/span&gt;&lt;/td&gt; 		&lt;td width="14%"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;A&lt;/span&gt;&lt;/td&gt; 		&lt;td width="12%"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;D&lt;/span&gt;&lt;/td&gt; 	&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;h3&gt;Conclusion :&lt;span class="Apple-style-span" style="font-weight: normal;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Times New Roman', serif; font-size: small; font-weight: normal;"&gt;Compare your Project requirements with DBMS. It depend on your application or project which is suitable for your project.&lt;/span&gt; &lt;/h3&gt;&lt;title&gt;&lt;/title&gt; 	 	&lt;style type="text/css"&gt;	&lt;!--		@page { margin: 2cm }		P { margin-bottom: 0.21cm }	--&gt;	&lt;/style&gt;   &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1497521753902285776-9059776161588814106?l=jagdeepmalhi.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jagdeepmalhi.blogspot.com/feeds/9059776161588814106/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://jagdeepmalhi.blogspot.com/2010/12/comparison-of-oracle-mysql-and-postgres.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1497521753902285776/posts/default/9059776161588814106'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1497521753902285776/posts/default/9059776161588814106'/><link rel='alternate' type='text/html' href='http://jagdeepmalhi.blogspot.com/2010/12/comparison-of-oracle-mysql-and-postgres.html' title='Comparison of Oracle, MySQL and Postgres DBMS'/><author><name>jagdeepsinghmalhi</name><uri>http://www.blogger.com/profile/08521786673136153319</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='26' src='http://1.bp.blogspot.com/_cKWqnDTAg-4/StdboO4vVMI/AAAAAAAAAAk/zqhdKK1K8vQ/S220/Photo%24072.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1497521753902285776.post-6982441093840625295</id><published>2010-11-28T01:02:00.004+05:30</published><updated>2011-06-09T23:25:56.262+05:30</updated><title type='text'>TMUX – The Terminal Multiplexer</title><content type='html'>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;&lt;div style="margin-bottom: 0cm;"&gt;&lt;em&gt;tmux &lt;/em&gt;&lt;em&gt;&lt;span style="font-style: normal;"&gt;is similar to screen as it lets you run numerous TTY’s in the same terminal window. It enables a number of terminals to be&lt;/span&gt;&lt;/em&gt;&lt;span style="font-style: normal;"&gt;created, accessed, and controlled from a single screen.  &lt;/span&gt;&lt;span style="font-style: normal;"&gt;&lt;b&gt;tmux&lt;/b&gt;&lt;/span&gt;&lt;span style="font-style: normal;"&gt; may be detached from a screen and continue running in the background, then later reattached.&lt;/span&gt;&lt;/div&gt;&lt;div style="font-style: normal; margin-bottom: 0cm;"&gt;Usecommand for attach after detached to reattached.  &lt;/div&gt;&lt;div style="margin-bottom: 0cm;"&gt;&lt;span style="font-style: normal;"&gt; &lt;/span&gt;&lt;span style="font-family: 'Times New Roman', serif;"&gt;&lt;i&gt;&lt;span style="font-weight: normal;"&gt;$ tmux attach&lt;/span&gt;&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="font-style: normal; margin-bottom: 0cm;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="font-style: normal; margin-bottom: 0cm;"&gt;When &lt;b&gt;tmux&lt;/b&gt; is started it creates a new session with a single window and  displays it on screen.  A status line at the bottom of the screen shows information on the current session and is used to enter interactive&lt;/div&gt;&lt;div style="font-style: normal; margin-bottom: 0cm;"&gt;commands.&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://1.bp.blogspot.com/_cKWqnDTAg-4/TPFdunkUYxI/AAAAAAAAADI/tjKoxZlWZ9A/s1600/Screenshot-1.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="200" src="http://1.bp.blogspot.com/_cKWqnDTAg-4/TPFdunkUYxI/AAAAAAAAADI/tjKoxZlWZ9A/s320/Screenshot-1.png" width="320" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;a name='more'&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0cm;"&gt;&lt;span class="Apple-style-span" style="font-size: 24.1667px; font-weight: bold;"&gt;&lt;em&gt;&lt;span style="font-style: normal;"&gt;Advantages&lt;/span&gt;&lt;/em&gt;&lt;/span&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;&lt;div style="margin-bottom: 0cm;"&gt;&lt;em&gt;&lt;span style="font-style: normal;"&gt;A  clearly defined cilent/server model (windows are their own clients  which allows flexibility on how you handle windows. You can attach  and detach different windows in different sessions without any  issues) &lt;/span&gt;&lt;/em&gt;  &lt;/div&gt;&lt;/li&gt;&lt;li&gt;&lt;div style="margin-bottom: 0cm;"&gt;Consistent, well-documented  command interface. (You can use the same commands interactively as  in the .tmux.conf file, more on that later)   &lt;/div&gt;&lt;/li&gt;&lt;li&gt;&lt;div style="margin-bottom: 0cm;"&gt;Easily scriptable   &lt;/div&gt;&lt;/li&gt;&lt;li&gt;&lt;div style="margin-bottom: 0cm;"&gt;Multiple paste buffers   &lt;/div&gt;&lt;/li&gt;&lt;li&gt;&lt;div style="margin-bottom: 0cm;"&gt;Vi &amp;amp; Emacs keybindings   &lt;/div&gt;&lt;/li&gt;&lt;li&gt;A more usable status line syntax (which also allows you to  embed the output of a shell command, handy indeed.   &lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;div style="margin-bottom: 0cm;"&gt;&lt;span class="Apple-style-span" style="font-size: 24.1667px; font-weight: bold;"&gt;&lt;em&gt;&lt;span style="font-style: normal;"&gt;Basic Commands&lt;/span&gt;&lt;/em&gt;&lt;/span&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;&lt;div style="margin-bottom: 0cm;"&gt;&lt;em&gt;Ctrl-b c&lt;/em&gt; Create new  window   &lt;/div&gt;&lt;/li&gt;&lt;li&gt;&lt;div style="margin-bottom: 0cm;"&gt;&lt;em&gt;Ctrl-b d&lt;/em&gt; Detach current  client   &lt;/div&gt;&lt;/li&gt;&lt;li&gt;&lt;div style="margin-bottom: 0cm;"&gt;&lt;strong&gt;Ctrl-b l&lt;/strong&gt; Move to  previously selected window   &lt;/div&gt;&lt;/li&gt;&lt;li&gt;&lt;div style="margin-bottom: 0cm;"&gt;&lt;strong&gt;Ctrl-b n&lt;/strong&gt; Move to  the next window   &lt;/div&gt;&lt;/li&gt;&lt;li&gt;&lt;div style="margin-bottom: 0cm;"&gt;&lt;strong&gt;Ctrl-b p&lt;/strong&gt; Move to  the previous window   &lt;/div&gt;&lt;/li&gt;&lt;li&gt;&lt;div style="margin-bottom: 0cm;"&gt;&lt;strong&gt;Ctrl-b &amp;amp;&lt;/strong&gt; Kill  the current window   &lt;/div&gt;&lt;/li&gt;&lt;li&gt;&lt;div style="margin-bottom: 0cm;"&gt;&lt;strong&gt;Ctrl-b ,&lt;/strong&gt; Rename  the current window   &lt;/div&gt;&lt;/li&gt;&lt;li&gt;&lt;div style="margin-bottom: 0cm;"&gt;&lt;strong&gt;Ctrl-b %&lt;/strong&gt; Split  the current window into two panes   &lt;/div&gt;&lt;/li&gt;&lt;li&gt;&lt;div style="margin-bottom: 0cm;"&gt;&lt;strong&gt;Ctrl-b q&lt;/strong&gt; Show  pane numbers (used to switch between panes)   &lt;/div&gt;&lt;/li&gt;&lt;li&gt;&lt;div style="margin-bottom: 0cm;"&gt;&lt;strong&gt;Ctrl-b o&lt;/strong&gt; Switch  to the next pane   &lt;/div&gt;&lt;/li&gt;&lt;li&gt;&lt;strong&gt;Ctrl-b ?&lt;/strong&gt; List all key bindings   &lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;&lt;div style="margin-bottom: 0cm;"&gt;&lt;strong&gt;Ctrl-b n&lt;/strong&gt; (Move to  the next window)   &lt;/div&gt;&lt;/li&gt;&lt;li&gt;&lt;div style="margin-bottom: 0cm;"&gt;&lt;strong&gt;Ctrl-b p&lt;/strong&gt; (Move to  the previous window)   &lt;/div&gt;&lt;/li&gt;&lt;li&gt;&lt;div style="margin-bottom: 0cm;"&gt;&lt;strong&gt;Ctrl-b l&lt;/strong&gt; (Move to  the previously selected window)   &lt;/div&gt;&lt;/li&gt;&lt;li&gt;&lt;div style="margin-bottom: 0cm;"&gt;&lt;strong&gt;Ctrl-b w&lt;/strong&gt; (List  all windows / window numbers)   &lt;/div&gt;&lt;/li&gt;&lt;li&gt;&lt;strong&gt;Ctrl-b &amp;lt;window number&amp;gt;&lt;/strong&gt; (Move to the  specified window number, the default bindings are from 0 – 9)   &lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;&lt;div style="margin-bottom: 0cm;"&gt;&lt;strong&gt;Ctrl-b %&lt;/strong&gt; (Split  the window vertically)   &lt;/div&gt;&lt;/li&gt;&lt;li&gt;&lt;div style="margin-bottom: 0cm;"&gt;&lt;strong&gt;Ctrl-b : “split-window”&lt;/strong&gt;  (Split window horizontally)   &lt;/div&gt;&lt;/li&gt;&lt;li&gt;&lt;div style="margin-bottom: 0cm;"&gt;&lt;strong&gt;Ctrl-b o&lt;/strong&gt; (Goto  next pane)   &lt;/div&gt;&lt;/li&gt;&lt;li&gt;&lt;div style="margin-bottom: 0cm;"&gt;&lt;strong&gt;Ctrl-b q&lt;/strong&gt; (Show  pane numbers, when the numbers show up type the key to goto that  pane)   &lt;/div&gt;&lt;/li&gt;&lt;li&gt;&lt;div style="margin-bottom: 0cm;"&gt;&lt;strong&gt;Ctrl-b {&lt;/strong&gt; (Move  the current pane left)   &lt;/div&gt;&lt;/li&gt;&lt;li&gt;&lt;strong&gt;Ctrl-b }&lt;/strong&gt; (Move the current pane right)   &lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;div style="margin-bottom: 0cm;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1497521753902285776-6982441093840625295?l=jagdeepmalhi.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jagdeepmalhi.blogspot.com/feeds/6982441093840625295/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://jagdeepmalhi.blogspot.com/2010/11/tmux-terminal-multiplexer.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1497521753902285776/posts/default/6982441093840625295'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1497521753902285776/posts/default/6982441093840625295'/><link rel='alternate' type='text/html' href='http://jagdeepmalhi.blogspot.com/2010/11/tmux-terminal-multiplexer.html' title='TMUX – The Terminal Multiplexer'/><author><name>jagdeepsinghmalhi</name><uri>http://www.blogger.com/profile/08521786673136153319</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='26' src='http://1.bp.blogspot.com/_cKWqnDTAg-4/StdboO4vVMI/AAAAAAAAAAk/zqhdKK1K8vQ/S220/Photo%24072.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_cKWqnDTAg-4/TPFdunkUYxI/AAAAAAAAADI/tjKoxZlWZ9A/s72-c/Screenshot-1.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1497521753902285776.post-2559449645829125573</id><published>2010-11-18T11:27:00.002+05:30</published><updated>2010-11-28T01:08:37.386+05:30</updated><title type='text'>Sphinx Auto genrate documentation for Django Project</title><content type='html'>&amp;nbsp;          &lt;style type="text/css"&gt;p { margin-bottom: 0.21cm; }h2 { margin-bottom: 0.21cm; }pre.cjk { font-family: "DejaVu Sans",monospace; }tt.cjk { font-family: "DejaVu Sans",monospace; }&lt;/style&gt;  &lt;br /&gt;&lt;div style="margin-bottom: 0cm;"&gt;Sphinx is a tool that makes it easy to create intelligent and beautiful documentation.&lt;/div&gt;&lt;h2&gt;Installing your doc directory&lt;/h2&gt;&lt;pre class="western" style="margin-bottom: 0.5cm;"&gt;python -c 'import sphinx'&lt;/pre&gt;If that fails grab the latest version of and install it with:&lt;br /&gt;&lt;pre class="western" style="margin-bottom: 0.5cm;"&gt;&amp;gt; sudo easy_install sphinx&lt;/pre&gt;Now you are ready to build a template for your docs, using sphinx-quickstart:&lt;br /&gt;&lt;pre class="western" style="margin-bottom: 0.5cm;"&gt;&amp;gt; sphinx-quickstart&lt;/pre&gt;accepting most of the defaults. I choose “sampledoc” as the name of my project. cd into your new directory and check the contents:&lt;br /&gt;&lt;pre class="western"&gt;home:~/tmp/sampledoc&amp;gt; ls&lt;br /&gt;Makefile      _static         conf.py&lt;br /&gt;_build                _templates      index.rst&lt;/pre&gt;&lt;br /&gt;The index.rst is the master ReST for your project, but before adding anything, let’s see if we can build some html:&lt;br /&gt;&lt;pre class="western" style="margin-bottom: 0.5cm;"&gt;make html&lt;/pre&gt;&lt;div style="margin-bottom: 0cm;"&gt;If you now point your browser to &lt;tt class="western"&gt;_build/html/index.html&lt;/tt&gt;, you should see a basic sphinx site.&lt;/div&gt;&lt;div style="margin-bottom: 0cm;"&gt;&lt;br /&gt;&lt;a name='more'&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0cm;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0.5cm;"&gt;This will create your basic documentation project. You should have a file layout something like this:&lt;/div&gt;&lt;ul&gt;&lt;li&gt;&lt;div style="margin-bottom: 0cm;"&gt;Makefile&amp;nbsp;&amp;nbsp;&amp;nbsp;   &lt;/div&gt;&lt;/li&gt;&lt;li&gt;&lt;div style="margin-bottom: 0cm;"&gt;_build&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;   &lt;/div&gt;&lt;/li&gt;&lt;li&gt;&lt;div style="margin-bottom: 0cm;"&gt;_static&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;   &lt;/div&gt;&lt;/li&gt;&lt;li&gt;&lt;div style="margin-bottom: 0cm;"&gt;_templates&amp;nbsp;&amp;nbsp;&amp;nbsp;   &lt;/div&gt;&lt;/li&gt;&lt;li&gt;&lt;div style="margin-bottom: 0cm;"&gt;conf.py&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;   &lt;/div&gt;&lt;/li&gt;&lt;li&gt;index.rst&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;div style="margin-bottom: 0cm;"&gt;&lt;/div&gt;.. and you build your documentation simply using the auto-generated build file:&lt;br /&gt;make html&lt;br /&gt;&lt;br /&gt;This will now generate a blank skeleton of your documentation ... not really very useful. &lt;br /&gt;&lt;br /&gt;&lt;b&gt; Adding some modules&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;Lets now add some modules for auto-documentation. Lets assume we are have an app called &lt;b&gt;myapp&lt;/b&gt;, and we have a &lt;b&gt;models.py&lt;/b&gt; module which we want to edit. &lt;br /&gt;&lt;br /&gt;In your documentation folder, create a directory called modules, then create a new file called models.rst. e.g.:&lt;br /&gt;mkdir modules&lt;br /&gt;nano modules/models.py&lt;br /&gt;&lt;br /&gt;Now edit models.py so that it looks something like this:&lt;br /&gt;&lt;br /&gt;myapp.models&lt;br /&gt;==================&lt;br /&gt;&lt;br /&gt;.. automodule:: myapp.models&lt;br /&gt;&amp;nbsp;&amp;nbsp; :members:&lt;br /&gt;&lt;br /&gt;now, if we run: &lt;br /&gt;make html&lt;br /&gt;&lt;br /&gt;you should get output something like the following:&lt;br /&gt;&lt;br /&gt;(test)-bash-3.2$ make html&lt;br /&gt;sphinx-build -b html -d _build/doctrees&amp;nbsp;&amp;nbsp; . _build/html&lt;br /&gt;Running Sphinx v0.6.3&lt;br /&gt;loading pickled environment... done&lt;br /&gt;building [html]: targets for 0 source files that are out of date&lt;br /&gt;updating environment: 1 added, 0 changed, 0 removed&lt;br /&gt;reading sources... [100%] modules/model&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;looking for now-outdated files... none found&lt;br /&gt;pickling environment... done&lt;br /&gt;&lt;b&gt;checking consistency... /Users/Me/Projects/MyApp/docs/modules/model.rst:: WARNING: document isn't included in any toctree&lt;/b&gt;&lt;br /&gt;done&lt;br /&gt;preparing documents... done&lt;br /&gt;writing output... [100%] modules/model&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;writing additional files... genindex search&lt;br /&gt;copying static files... done&lt;br /&gt;dumping search index... done&lt;br /&gt;dumping object inventory... done&lt;br /&gt;build succeeded, 1 warning.&lt;br /&gt;&lt;br /&gt;Note the warning in bold. We need to add a link to our documentation from a page. so .. open up index.rst in your documentation root dir, and add something like this:&lt;br /&gt;&lt;br /&gt;Modules&lt;br /&gt;==================&lt;br /&gt;&lt;br /&gt;.. toctree::&lt;br /&gt;&amp;nbsp;&amp;nbsp; :maxdepth: 2&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp; modules/model.rst&lt;br /&gt;&lt;br /&gt;running it again, you should now get a new error:&lt;br /&gt;&lt;br /&gt;/Users/Me/Projects/MyApp/docs/modules/models.rst:4: (WARNING/2) autodoc can't import/find module 'myapp.model', it reported error: "No module named myapp.model", please check your spelling and sys.path&lt;br /&gt;&lt;div style="margin-bottom: 0cm;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0cm;"&gt;&lt;b&gt;Configuring your django app&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;We do as above opening my conf.py file, it now looks something like this:&lt;br /&gt;&lt;br /&gt;# If extensions (or modules to document with autodoc) are in another directory,&lt;br /&gt;# add these directories to sys.path here. If the directory is relative to the&lt;br /&gt;# documentation root, use os.path.abspath to make it absolute, like shown here.&lt;br /&gt;sys.path.append('/Users/Me/Projects/MyApp/src/myapp')&lt;br /&gt;#setup django&lt;br /&gt;import settings&lt;br /&gt;from django.core.management import setup_environ&lt;br /&gt;setup_environ(settings)&lt;br /&gt;&lt;br /&gt;.. and finally, we run:&lt;br /&gt;make html&lt;br /&gt;&lt;br /&gt;.. and great success, I now have autodocumented modules in my documentation.&lt;/div&gt;&lt;div style="margin-bottom: 0cm;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0cm;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0cm;"&gt;For more Detail &lt;a href="http://showmedo.com/videotutorials/video?name=2910020"&gt;Click Here&lt;/a&gt;  &lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1497521753902285776-2559449645829125573?l=jagdeepmalhi.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jagdeepmalhi.blogspot.com/feeds/2559449645829125573/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://jagdeepmalhi.blogspot.com/2010/11/sphinx-auto-genrate-documentation-for.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1497521753902285776/posts/default/2559449645829125573'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1497521753902285776/posts/default/2559449645829125573'/><link rel='alternate' type='text/html' href='http://jagdeepmalhi.blogspot.com/2010/11/sphinx-auto-genrate-documentation-for.html' title='Sphinx Auto genrate documentation for Django Project'/><author><name>jagdeepsinghmalhi</name><uri>http://www.blogger.com/profile/08521786673136153319</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='26' src='http://1.bp.blogspot.com/_cKWqnDTAg-4/StdboO4vVMI/AAAAAAAAAAk/zqhdKK1K8vQ/S220/Photo%24072.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1497521753902285776.post-8784626314320580159</id><published>2010-10-25T21:20:00.004+05:30</published><updated>2010-11-18T11:04:01.544+05:30</updated><title type='text'>Django-Cms Installation error "PageAdmin.exclude' refers to field 'created_by' that is missing from"</title><content type='html'>&lt;span class="Apple-style-span" style="font-size: x-large;"&gt;&lt;b&gt;  &lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;div style="font-style: normal; margin-bottom: 0cm; orphans: 2; widows: 2;"&gt;&lt;span style="color: black;"&gt;&lt;span style="font-family: 'Times New Roman';"&gt;&lt;b&gt;Error :&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;pre style="orphans: 2; widows: 2;"&gt;&lt;span style="color: black;"&gt;&lt;span style="font-family: 'Times New Roman';"&gt;&lt;span style="font-style: normal;"&gt;&lt;span style="font-weight: normal;"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;Error "ImproperlyConfigured at / 'PageAdmin.exclude' refers to field 'created_by' that is&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="orphans: 2; widows: 2;"&gt;&lt;span style="color: black;"&gt;&lt;span style="font-family: 'Times New Roman';"&gt;&lt;span style="font-style: normal;"&gt;&lt;span style="font-weight: normal;"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;missing from the form" &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: black;"&gt;&lt;span style="font-family: Times,'Times New Roman',serif;"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;Problem Solve :&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: black;"&gt;&lt;span style="font-family: Times,'Times New Roman',serif;"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;Fixed this error &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: black;"&gt;&lt;span style="font-family: Times,'Times New Roman',serif;"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;by just setting editable=False on created_by and changed_by and removing all fields from&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="orphans: 2; widows: 2;"&gt;&lt;span style="color: black;"&gt;&lt;span style="font-family: Times,'Times New Roman',serif;"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;PageAdmin.exclude (the other fields already were editable=False)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: black;"&gt;&lt;span style="font-family: Times,'Times New Roman',serif;"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;Edit two files to fix this error&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="orphans: 2; widows: 2;"&gt;&lt;span style="color: black; font-size: large;"&gt;&lt;span class="Apple-style-span"&gt;&lt;span class="Apple-style-span" style="font-family: Times,'Times New Roman',serif;"&gt;&lt;b&gt;&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="orphans: 2; widows: 2;"&gt;&lt;span style="color: black; font-size: large;"&gt;&lt;span class="Apple-style-span"&gt;&lt;span class="Apple-style-span" style="font-family: Times,'Times New Roman',serif;"&gt;&lt;b&gt;Edit f&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color: black; font-size: large;"&gt;&lt;span class="Apple-style-span"&gt;&lt;span class="Apple-style-span" style="font-family: Times,'Times New Roman',serif;"&gt;&lt;b&gt;ile:&lt;/b&gt; &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"&gt;&lt;span class="Apple-style-span" style="font-family: Times,'Times New Roman',serif;"&gt;cms/admin/pageadmin.py&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: black; font-size: small;"&gt;&lt;span style="font-family: 'Times New Roman';"&gt;&lt;span style="font-style: normal;"&gt;&lt;b&gt;&lt;span class="Apple-style-span"&gt;Line no. 65 approximately. &lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: black;"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="font-family: 'Courier New',Courier,monospace;"&gt;&lt;span style="font-style: normal;"&gt;&lt;span style="font-weight: normal;"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;revision_form_template&amp;nbsp;=&amp;nbsp;"admin/cms/page/revision_form.html"&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family: Times,'Times New Roman',serif;"&gt;&lt;b&gt;&lt;span style="color: black;"&gt;&lt;span style="font-style: normal;"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span style="font-size: small;"&gt;Change this li&lt;span style="font-size: small;"&gt;n&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: small;"&gt;e&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: black;"&gt;&lt;span style="font-family: 'Times New Roman';"&gt;&lt;span style="font-family: 'Courier New',Courier,monospace;"&gt;&lt;span style="font-weight: normal;"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;-&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;exclude&amp;nbsp;=&amp;nbsp;['created_by',&amp;nbsp;'changed_by',&amp;nbsp;'lft',&amp;nbsp;'rght',&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="orphans: 2; widows: 2;"&gt;&lt;span style="color: black;"&gt;&lt;span style="font-family: 'Times New Roman';"&gt;&lt;span style="font-family: 'Courier New',Courier,monospace;"&gt;&lt;span style="font-weight: normal;"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;'tree_id', 'level']&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: black;"&gt;&lt;span style="font-family: 'Times New Roman';"&gt;&lt;b&gt;&lt;span style="font-family: Times,'Times New Roman',serif;"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span style="font-size: small;"&gt;by&lt;/span&gt; &lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: black;"&gt;&lt;span style="font-family: 'Courier New',Courier,monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;+&amp;nbsp; exclude&amp;nbsp;=&amp;nbsp;[]&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="color: black;"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="orphans: 2; widows: 2;"&gt;&lt;span style="color: black;"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style="color: black;"&gt;&lt;span style="font-family: 'Courier New',Courier,monospace;"&gt;&lt;span style="font-style: normal;"&gt;&lt;span style="font-weight: normal;"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;mandatory_placeholders&amp;nbsp;=&amp;nbsp;('title',&amp;nbsp;'slug',&amp;nbsp;'parent',&amp;nbsp;'site', &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color: black;"&gt;&lt;span style="font-family: 'Courier New',Courier,monospace;"&gt;&lt;span style="font-style: normal;"&gt;&lt;span style="font-weight: normal;"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="orphans: 2; widows: 2;"&gt;&lt;span style="color: black;"&gt;&lt;span style="font-family: 'Courier New',Courier,monospace;"&gt;&lt;span style="font-style: normal;"&gt;&lt;span style="font-weight: normal;"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;'meta_description',&amp;nbsp;'meta_keywords',&amp;nbsp;'page_title',&amp;nbsp;'menu_title')&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color: black;"&gt;&lt;span style="font-family: 'Courier New',Courier,monospace;"&gt;&lt;span style="font-style: normal;"&gt;&lt;span style="font-weight: normal;"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="orphans: 2; widows: 2;"&gt;&lt;span style="color: black;"&gt;&lt;span style="font-family: 'Courier New',Courier,monospace;"&gt;&lt;span style="font-style: normal;"&gt;&lt;span style="font-weight: normal;"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;top_fields&amp;nbsp;=&amp;nbsp;[]&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&amp;nbsp;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: black;"&gt;&lt;span style="font-family: 'Courier New',Courier,monospace;"&gt;&lt;span style="font-style: normal;"&gt;&lt;span style="font-weight: normal;"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt; general_fields&amp;nbsp;=&amp;nbsp;['title',&amp;nbsp;'slug',&amp;nbsp;('published',&amp;nbsp;'in_navigation')]&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: black;"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt; &lt;a name='more'&gt;&lt;/a&gt; &amp;nbsp;  &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: black; font-size: large;"&gt;&lt;span class="Apple-style-span"&gt;&lt;span class="Apple-style-span" style="font-family: Times,'Times New Roman',serif;"&gt;&lt;b&gt;Edit File :&lt;/b&gt; cms/admin/pagemodel.py&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: black;"&gt;&lt;b&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: Times,'Times New Roman',serif;"&gt;line no. 40 approximately &lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: black;"&gt;&lt;span style="font-family: 'Courier New',Courier,monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;template_choices&amp;nbsp;=&amp;nbsp;[(x,&amp;nbsp;_(y))&amp;nbsp;for&amp;nbsp;x,y&amp;nbsp;in&amp;nbsp;settings.CMS_TEMPLATES]&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: black; font-size: small;"&gt;&lt;span style="font-family: 'Courier New',Courier,monospace;"&gt;&lt;b&gt;&lt;span class="Apple-style-span"&gt;change following lines &lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: black;"&gt;&lt;span style="font-family: 'Courier New',Courier,monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;-&amp;nbsp;&amp;nbsp;&amp;nbsp;created_by&amp;nbsp;=&amp;nbsp;models.CharField(_("created&amp;nbsp;by"),&amp;nbsp;max_length=70)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: black;"&gt;&lt;span style="font-family: 'Courier New',Courier,monospace;"&gt;&lt;span style="font-style: normal;"&gt;&lt;span style="font-weight: normal;"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;-&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;changed_by&amp;nbsp;=&amp;nbsp;models.CharField(_("changed&amp;nbsp;by"),&amp;nbsp;max_length=70)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: black;"&gt;&lt;span style="font-family: 'Courier New',Courier,monospace;"&gt;&lt;span style="font-size: small;"&gt;&lt;b&gt;&lt;span class="Apple-style-span"&gt;by&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: black;"&gt;&lt;span style="font-family: 'Courier New',Courier,monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;+&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;created_by&amp;nbsp;=&amp;nbsp;models.CharField(_("created&amp;nbsp;by"),&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="orphans: 2; widows: 2;"&gt;&lt;span style="color: black;"&gt;&lt;span style="font-family: 'Courier New',Courier,monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;max_length=70,&amp;nbsp;editable=False)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: black;"&gt;&lt;span style="font-family: 'Courier New',Courier,monospace;"&gt;&lt;span style="font-style: normal;"&gt;&lt;span style="font-weight: normal;"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;+&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;changed_by&amp;nbsp;=&amp;nbsp;models.CharField(_("changed&amp;nbsp;by"),&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="orphans: 2; widows: 2;"&gt;&lt;span style="color: black;"&gt;&lt;span style="font-family: 'Courier New',Courier,monospace;"&gt;&lt;span style="font-style: normal;"&gt;&lt;span style="font-weight: normal;"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&amp;nbsp;max_length=70,&amp;nbsp;editable=False)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: black;"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style="color: black;"&gt;&lt;span style="font-family: 'Courier New',Courier,monospace;"&gt;&lt;span style="font-style: normal;"&gt;&lt;span style="font-weight: normal;"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;parent&amp;nbsp;=&amp;nbsp;models.ForeignKey('self',&amp;nbsp;null=True, blank=True,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="orphans: 2; widows: 2;"&gt;&lt;span style="color: black;"&gt;&lt;span style="font-family: 'Courier New',Courier,monospace;"&gt;&lt;span style="font-style: normal;"&gt;&lt;span style="font-weight: normal;"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&amp;nbsp;related_name='children',&amp;nbsp;db_index=True)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: black;"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style="font-family: 'Courier New',Courier,monospace;"&gt;&lt;span style="font-style: normal;"&gt;&lt;span style="font-weight: normal;"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;creation_date&amp;nbsp;=&amp;nbsp;models.DateTimeField(editable=False,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="orphans: 2; widows: 2;"&gt;&lt;span style="color: black;"&gt;&lt;span style="font-family: 'Courier New',Courier,monospace;"&gt;&lt;span style="font-style: normal;"&gt;&lt;span style="font-weight: normal;"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&amp;nbsp;default=datetime.now)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: black;"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;b&gt;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;&lt;pre&gt;&lt;/pre&gt;&lt;/b&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1497521753902285776-8784626314320580159?l=jagdeepmalhi.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jagdeepmalhi.blogspot.com/feeds/8784626314320580159/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://jagdeepmalhi.blogspot.com/2010/10/django-cms-installation-error.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1497521753902285776/posts/default/8784626314320580159'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1497521753902285776/posts/default/8784626314320580159'/><link rel='alternate' type='text/html' href='http://jagdeepmalhi.blogspot.com/2010/10/django-cms-installation-error.html' title='Django-Cms Installation error &quot;PageAdmin.exclude&apos; refers to field &apos;created_by&apos; that is missing from&quot;'/><author><name>jagdeepsinghmalhi</name><uri>http://www.blogger.com/profile/08521786673136153319</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='26' src='http://1.bp.blogspot.com/_cKWqnDTAg-4/StdboO4vVMI/AAAAAAAAAAk/zqhdKK1K8vQ/S220/Photo%24072.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1497521753902285776.post-3888662960629961895</id><published>2010-09-20T22:18:00.001+05:30</published><updated>2010-09-20T22:20:45.607+05:30</updated><title type='text'>Python : Virtual Python Environment builder</title><content type='html'>&lt;span class="Apple-style-span" style="font-family: Arial; font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-size: 16px;"&gt;&lt;span class="Apple-style-span" style="font-size: x-large;"&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;&lt;b&gt;Virtual Python Environment builder&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;div&gt;&lt;tt class="docutils literal"&gt;&lt;span class="pre"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;virtualenv&lt;/span&gt;&lt;/span&gt;&lt;/tt&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt; is a tool to create isolated Python environments.&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;The basic problem being addressed is one of dependencies and versions, and indirectly permissions.  Imagine you have an application that needs version 1 of LibFoo, but another application requires version 2.  How can you use both these applications?  If you install everything into &lt;/span&gt;&lt;tt class="docutils literal"&gt;&lt;span class="pre"&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;/&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;usr/lib/python2.4/site-packages&lt;/span&gt;&lt;/span&gt;&lt;/tt&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt; (or whatever your platform's standard location is), it's easy to end up in a situation where you unintentionally upgrade an application that shouldn't be upgraded.&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;Or more generally, what if you want to install an application &lt;/span&gt;&lt;em&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;and leave it be&lt;/span&gt;&lt;/em&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;?  If an application works, any change in its libraries or the versions of those libraries can break the application.&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;Also, what if you can't install packages into the global &lt;/span&gt;&lt;tt class="docutils literal"&gt;&lt;span class="pre"&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;site-packages&lt;/span&gt;&lt;/span&gt;&lt;/tt&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt; directory?  For instance, on a shared host.&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;In all these cases, &lt;/span&gt;&lt;tt class="docutils literal"&gt;&lt;span class="pre"&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;virtualenv&lt;/span&gt;&lt;/span&gt;&lt;/tt&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt; can help you.  It creates an environment that has its own installation directories, that doesn't share libraries with other &lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;virtualenv &lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;environments (and optionally doesn't use the globally installed libraries either).&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The basic usage is:&lt;br /&gt;&lt;pre class="literal-block"&gt;$ python virtualenv.py ENV&lt;br /&gt;&lt;/pre&gt;&lt;pre class="literal-block"&gt;&lt;a name='more'&gt;&lt;/a&gt;&lt;/pre&gt;&lt;pre class="literal-block"&gt;&lt;div class="section" id="the-no-site-packages-option"&gt;&lt;h2&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;The &lt;/span&gt;&lt;tt class="docutils literal"&gt;&lt;span class="pre"&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;--no-site-packages&lt;/span&gt;&lt;/span&gt;&lt;/tt&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt; Option&lt;/span&gt;&lt;/h2&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;If you build with &lt;/span&gt;&lt;tt class="docutils literal"&gt;&lt;span class="pre"&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;virtualenv&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt; &lt;/span&gt;&lt;span class="pre"&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;--no-site-packages&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt; &lt;/span&gt;&lt;span class="pre"&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;ENV&lt;/span&gt;&lt;/span&gt;&lt;/tt&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt; it will &lt;/span&gt;&lt;em&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;not&lt;/span&gt;&lt;/em&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;&lt;br /&gt;inherit any packages from &lt;/span&gt;&lt;tt class="docutils literal"&gt;&lt;span class="pre"&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;/usr/lib/python2.5/site-packages&lt;/span&gt;&lt;/span&gt;&lt;/tt&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt; (or&lt;br /&gt;wherever your global site-packages directory is).  This can be used if&lt;br /&gt;you don't have control over site-packages and don't want to depend on&lt;br /&gt;the packages there, or you just want more isolation from the global&lt;br /&gt;system.&lt;/span&gt;&lt;/div&gt;&lt;div class="section" id="using-virtualenv-without-bin-python"&gt;&lt;h2&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;Using Virtualenv without &lt;/span&gt;&lt;tt class="docutils literal"&gt;&lt;span class="pre"&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;bin/python&lt;/span&gt;&lt;/span&gt;&lt;/tt&gt;&lt;/h2&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;Sometimes you can't or don't want to use the Python interpreter&lt;br /&gt;created by the virtualenv.  For instance, in a&lt;a href="http://www.blogger.com/goog_412904932"&gt; &lt;/a&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;mod_python&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt; or&lt;a href="http://www.blogger.com/goog_412904928"&gt; &lt;/a&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;mod_wsgi&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;&lt;br /&gt;environment, there is only one interpreter.&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;Luckily, it's easy.  You must use the custom Python interpreter to&lt;br /&gt;&lt;/span&gt;&lt;em&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;install&lt;/span&gt;&lt;/em&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt; libraries.  But to &lt;/span&gt;&lt;em&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;use&lt;/span&gt;&lt;/em&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt; libraries, you just have to be sure&lt;br /&gt;the path is correct.  A script is available to correct the path.  You&lt;br /&gt;can setup the environment like:&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;pre class="literal-block"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;activate_this = '/path/to/env/bin/activate_this.py'&lt;br /&gt;execfile(activate_this, dict(__file__=activate_this))&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/pre&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;This will change &lt;/span&gt;&lt;tt class="docutils literal"&gt;&lt;span class="pre"&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;sys.path&lt;/span&gt;&lt;/span&gt;&lt;/tt&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt; and even change &lt;/span&gt;&lt;tt class="docutils literal"&gt;&lt;span class="pre"&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;sys.prefix&lt;/span&gt;&lt;/span&gt;&lt;/tt&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;, but alsoallow you to use an existing interpreter.  Items in your environmentwill show up first on &lt;/span&gt;&lt;tt class="docutils literal"&gt;&lt;span class="pre"&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;sys.path&lt;/span&gt;&lt;/span&gt;&lt;/tt&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;, before global items.  However,this cannot undo the activation of other environments, or modules thathave been imported.  You shouldn't try to, for instance, activate anenvironment before a web request; you should activate &lt;/span&gt;&lt;em&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;one&lt;/span&gt;&lt;/em&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;environment as early as possible, and not do it again in that process.&lt;/span&gt;&lt;/div&gt;&lt;div class="section" id="using-virtualenv-without-bin-python"&gt;&lt;span class="Apple-style-span" style="font-family: 'Times New Roman';"&gt;&lt;span class="Apple-style-span" style="white-space: normal;"&gt;&lt;span class="Apple-style-span" style="font-family: monospace;"&gt;&lt;span class="Apple-style-span" style="white-space: pre;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;a href="http://pypi.python.org/packages/source/v/virtualenv/virtualenv-1.5.1.tar.gz#md5=3daa1f449d5d2ee03099484cecb1c2b7"&gt;Download Link&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;&lt;span class="Apple-style-span" style="font-size: x-large;"&gt;Using with ModWSGI &lt;i&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-weight: normal;"&gt;(&lt;/span&gt;&lt;/span&gt;&lt;/i&gt;&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;i&gt;Python WSGI adapter module for Apache.)&lt;/i&gt;&lt;br /&gt;&lt;br /&gt;A virtual Python environment is useful where it is necessary to run  multiple WSGI applications which have conflicting requirements as to  what version of a Python module or package needs to be installed. They  can also be used where Apache and daemon mode of mod_wsgi is used to  host WSGI applications for different users and each user wants to be  able to separately install their own Python modules and packages.&lt;br /&gt;&lt;br /&gt;&lt;h2&gt;&lt;span class="Apple-style-span" style="font-weight: normal;"&gt;&lt;i&gt;Baseline Environment&lt;/i&gt;&lt;/span&gt;&lt;/h2&gt;The  first step in using virtual environments with mod_wsgi is to point  mod_wsgi at a baseline Python environment. This step is actually  optional and if not done the main Python installation for the system,  usually that which mod_wsgi was compiled for, would be used as the  baseline environment. &lt;br /&gt;Although the main Python installation can  be used, especially in a shared environment where daemon mode of  mod_wsgi is used to host WSGI applications for different users, it is  better to make the baseline environment a virgin environment with an  effectively empty 'site-packages' directory. This way there is no  possibility of conflicts between modules and packages in a users  individual Python virtual environment and the baseline environment. &lt;br /&gt;To  create a virgin environment using the 'virtualenv' program, the  '--no-site-packages' option should be supplied when creating the  environment. &lt;br /&gt;&lt;pre class="prettyprint"&gt;&lt;span class="pln"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;$ cd &lt;/span&gt;&lt;/span&gt;&lt;span class="pun"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;/&lt;/span&gt;&lt;/span&gt;&lt;span class="pln"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;usr&lt;/span&gt;&lt;/span&gt;&lt;span class="pun"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;/&lt;/span&gt;&lt;/span&gt;&lt;span class="kwd"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;local&lt;/span&gt;&lt;/span&gt;&lt;span class="pun"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;/&lt;/span&gt;&lt;/span&gt;&lt;span class="pln"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;pythonenv&lt;br /&gt;$ virtualenv &lt;/span&gt;&lt;/span&gt;&lt;span class="pun"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;--&lt;/span&gt;&lt;/span&gt;&lt;span class="kwd"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;no&lt;/span&gt;&lt;/span&gt;&lt;span class="pun"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;-&lt;/span&gt;&lt;/span&gt;&lt;span class="pln"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;site&lt;/span&gt;&lt;/span&gt;&lt;span class="pun"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;-&lt;/span&gt;&lt;/span&gt;&lt;span class="pln"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;packages BASELINE&lt;/span&gt;&lt;/span&gt;&lt;span class="typ"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;New&lt;/span&gt;&lt;/span&gt;&lt;span class="pln"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt; python executable &lt;/span&gt;&lt;/span&gt;&lt;span class="kwd"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;in&lt;/span&gt;&lt;/span&gt;&lt;span class="pln"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt; BASELINE&lt;/span&gt;&lt;/span&gt;&lt;span class="pun"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;/&lt;/span&gt;&lt;/span&gt;&lt;span class="pln"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;bin&lt;/span&gt;&lt;/span&gt;&lt;span class="pun"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;/&lt;/span&gt;&lt;/span&gt;&lt;span class="pln"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;python&lt;/span&gt;&lt;/span&gt;&lt;span class="typ"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;Installing&lt;/span&gt;&lt;/span&gt;&lt;span class="pln"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt; setuptools&lt;/span&gt;&lt;/span&gt;&lt;span class="pun"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;............&lt;/span&gt;&lt;/span&gt;&lt;span class="kwd"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;done&lt;/span&gt;&lt;/span&gt;&lt;span class="pun"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;.&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="prettyprint"&gt;&lt;span class="Apple-style-span" style="font-family: 'Times New Roman'; white-space: normal;"&gt;&lt;i&gt;&lt;br /&gt;&lt;div style="display: inline !important;"&gt;&lt;span class="Apple-style-span" style="font-style: normal;"&gt;Once the baseline Python environment has been created, the &lt;br /&gt;WSGIPythonHome directive should be defined within the global part of the&lt;br /&gt; main Apache configuration files. The directive should refer to the top &lt;br /&gt;level directory for the baseline environment created by the 'virtualenv'&lt;br /&gt; script.&lt;/span&gt;&lt;/div&gt;&lt;/i&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="prettyprint"&gt;&lt;span class="Apple-style-span" style="font-family: 'Times New Roman'; white-space: normal;"&gt;&lt;i&gt;&lt;br /&gt;&lt;div style="display: inline !important;"&gt;&lt;span class="Apple-style-span" style="font-style: normal;"&gt;&lt;/span&gt;&lt;/div&gt;&lt;/i&gt;&lt;/span&gt;&lt;i&gt;&lt;/i&gt;&lt;br /&gt;&lt;i&gt;&lt;pre class="prettyprint" style="display: inline !important;"&gt;&lt;span class="typ"&gt;&lt;span class="Apple-style-span" style="font-style: normal;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;WSGIPythonHome&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="pln"&gt;&lt;span class="Apple-style-span" style="font-style: normal;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="pun"&gt;&lt;span class="Apple-style-span" style="font-style: normal;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;/&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="pln"&gt;&lt;span class="Apple-style-span" style="font-style: normal;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;usr&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="pun"&gt;&lt;span class="Apple-style-span" style="font-style: normal;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;/&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="kwd"&gt;&lt;span class="Apple-style-span" style="font-style: normal;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;local&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="pun"&gt;&lt;span class="Apple-style-span" style="font-style: normal;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;/&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="pln"&gt;&lt;span class="Apple-style-span" style="font-style: normal;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;pythonenv&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="pun"&gt;&lt;span class="Apple-style-span" style="font-style: normal;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;/&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="pln"&gt;&lt;span class="Apple-style-span" style="font-style: normal;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;BASELINE&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/i&gt;&lt;/pre&gt;&lt;i&gt;&lt;/i&gt;&lt;br /&gt;&lt;i&gt;&lt;span class="Apple-style-span" style="font-style: normal;"&gt;This  Python environment will now be used as the baseline environment for all  WSGI applications running under mod_wsgi, whether they be run in  embedded mode or daemon mode. &lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-style: normal;"&gt;There is no need to set the  WSGIPythonHome directive if you want to use the main Python installation  as the baseline environment.&amp;nbsp;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-style: normal;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;&lt;span class="Apple-style-span" style="font-size: x-large;"&gt;For Applications&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-style: normal;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-style: normal;"&gt; As an additional step, the WSGI script file described in the  instructions would be modified to overlay the virtual environment for  the application on top of the baseline environment. This would be done  by adding at the very start of the WSGI script file the following: &lt;/span&gt; &lt;/i&gt;&lt;br /&gt;&lt;pre class="prettyprint"&gt;&lt;span class="kwd"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;import&lt;/span&gt;&lt;/span&gt;&lt;span class="pln"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt; site&lt;br /&gt;site&lt;/span&gt;&lt;/span&gt;&lt;span class="pun"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;.&lt;/span&gt;&lt;/span&gt;&lt;span class="pln"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;addsitedir&lt;/span&gt;&lt;/span&gt;&lt;span class="pun"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span class="str"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;'/usr/local/pythonenv/PYLONS-1/lib/python2.5/site-packages'&lt;/span&gt;&lt;/span&gt;&lt;span class="pun"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;i&gt;&lt;span class="Apple-style-span" style="font-style: normal;"&gt;&lt;br /&gt;Note  that in this case the full path to the 'site-packages' directory for  the virtual environment needs to be specified and not just the root of  the virtual environment.&lt;/span&gt; &lt;br /&gt;&lt;span class="Apple-style-span" style="font-style: normal;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/i&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1497521753902285776-3888662960629961895?l=jagdeepmalhi.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jagdeepmalhi.blogspot.com/feeds/3888662960629961895/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://jagdeepmalhi.blogspot.com/2010/09/python-virtual-python-environment.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1497521753902285776/posts/default/3888662960629961895'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1497521753902285776/posts/default/3888662960629961895'/><link rel='alternate' type='text/html' href='http://jagdeepmalhi.blogspot.com/2010/09/python-virtual-python-environment.html' title='Python : Virtual Python Environment builder'/><author><name>jagdeepsinghmalhi</name><uri>http://www.blogger.com/profile/08521786673136153319</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='26' src='http://1.bp.blogspot.com/_cKWqnDTAg-4/StdboO4vVMI/AAAAAAAAAAk/zqhdKK1K8vQ/S220/Photo%24072.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1497521753902285776.post-6195367828231735637</id><published>2010-09-10T15:58:00.006+05:30</published><updated>2010-11-28T01:09:25.598+05:30</updated><title type='text'>Django : FileField() or  ImageField()</title><content type='html'>&lt;span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"&gt;In Django its very simple to handle images and file field.&lt;/span&gt;&lt;br /&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"&gt;First you define the ImageField and FileField in Class.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"&gt;for&amp;nbsp;example :&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"&gt;Class File(models.Model):&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"&gt;image =models.ImageField(upload_to = 'path')&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"&gt;File =models.FileField(upload_to = 'path')&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"&gt;Using a &lt;/span&gt;&lt;tt class="xref py py-class docutils literal"&gt;&lt;span class="pre"&gt;&lt;span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"&gt;FileField&lt;/span&gt;&lt;/span&gt;&lt;/tt&gt;&lt;span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"&gt; or an&lt;a href="http://www.blogger.com/goog_2017273574"&gt; &lt;/a&gt;&lt;/span&gt;&lt;tt class="xref py py-class docutils literal"&gt;&lt;span class="pre"&gt;&lt;span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"&gt;ImageField&lt;/span&gt;&lt;/span&gt;&lt;/tt&gt;&lt;span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"&gt; in a model takes a few steps:&lt;/span&gt;&lt;br /&gt;&lt;ol class="arabic simple"&gt;&lt;li&gt;&lt;span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"&gt;In your settings file, you'll need to define &lt;/span&gt;&lt;tt class="xref std std-setting docutils literal"&gt;&lt;span class="pre"&gt;&lt;span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"&gt;MEDIA_ROOT&lt;/span&gt;&lt;/span&gt;&lt;/tt&gt;&lt;span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"&gt; as the full path to a directory where you'd like Django to store uploaded files. (For performance, these files are not stored in the database.) Define &lt;/span&gt;&lt;tt class="xref std std-setting docutils literal"&gt;&lt;span class="pre"&gt;&lt;span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"&gt;MEDIA_URL&lt;/span&gt;&lt;/span&gt;&lt;/tt&gt;&lt;span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"&gt; as the base public URL of that directory. &lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;For Example :MEDIA_ROOT = "/media/"&amp;nbsp;&amp;nbsp;,&amp;nbsp;MEDIA_URL = 'http://localhost/media/'&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"&gt;Add the &lt;/span&gt;&lt;tt class="xref py py-class docutils literal"&gt;&lt;span class="pre"&gt;&lt;span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"&gt;FileField&lt;/span&gt;&lt;/span&gt;&lt;/tt&gt;&lt;span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"&gt; or &lt;/span&gt;&lt;tt class="xref py py-class docutils literal"&gt;&lt;span class="pre"&gt;&lt;span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"&gt;ImageField&lt;/span&gt;&lt;/span&gt;&lt;/tt&gt;&lt;span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"&gt; to your model, making sure to define the &lt;/span&gt;&lt;tt class="xref py py-attr docutils literal"&gt;&lt;span class="pre"&gt;&lt;span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"&gt;upload_to&lt;/span&gt;&lt;/span&gt;&lt;/tt&gt;&lt;span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"&gt; option to tell Django to which subdirectory of &lt;/span&gt;&lt;tt class="xref std std-setting docutils literal"&gt;&lt;span class="pre"&gt;&lt;span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"&gt;MEDIA_ROOT&lt;/span&gt;&lt;/span&gt;&lt;/tt&gt;&lt;span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"&gt; it should upload files.&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"&gt;All that will be stored in your database is a path to the file (relative to &lt;/span&gt;&lt;tt class="xref std std-setting docutils literal"&gt;&lt;span class="pre"&gt;&lt;span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"&gt;MEDIA_ROOT&lt;/span&gt;&lt;/span&gt;&lt;/tt&gt;&lt;span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"&gt;). You'll most likely want to use the convenience &lt;/span&gt;&lt;tt class="xref py py-attr docutils literal"&gt;&lt;span class="pre"&gt;&lt;span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"&gt;url&lt;/span&gt;&lt;/span&gt;&lt;/tt&gt;&lt;span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"&gt; attribute provided by Django. For example, if your &lt;/span&gt;&lt;tt class="xref py py-class docutils literal"&gt;&lt;span class="pre"&gt;&lt;span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"&gt;ImageField&lt;/span&gt;&lt;/span&gt;&lt;/tt&gt;&lt;span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"&gt; is called file&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"&gt;, you can get the absolute URL to your image in a template with&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt; &lt;/span&gt;&lt;tt class="docutils literal"&gt;&lt;span class="pre"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;{{&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt; &lt;/span&gt;&lt;span class="pre"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;object.file.url&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt; &lt;/span&gt;&lt;span class="pre"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;}}&lt;/span&gt;&lt;/span&gt;&lt;/tt&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;.&lt;/span&gt;&lt;/li&gt;&lt;/ol&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span class="Apple-style-span" style="font-size: x-large;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span class="Apple-style-span" style="font-size: x-large;"&gt;&lt;a name='more'&gt;&lt;/a&gt;Facing problem With ImageField() and FileField()&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;#python manage.py runserver&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;b&gt;Error &lt;/b&gt;:&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; white-space: pre;"&gt;Unhandled exception in thread started by&amp;nbsp;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;pre class="exception_value" style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;lt;function inner_run at 0x912348c&amp;gt;&lt;br /&gt;Traceback (most recent call last):&lt;br /&gt;  File "/usr/local/lib/python2.6/dist-packages/django/core/management&lt;/span&gt;&lt;/pre&gt;&lt;pre class="exception_value" style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;/commands/runserver.py", line 48, in inner_run&lt;br /&gt;    self.validate(display_num_errors=True)&lt;br /&gt;  File "/usr/local/lib/python2.6/dist-packages/django/core&lt;/span&gt;&lt;/pre&gt;&lt;pre class="exception_value" style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;/management/base.py", line 249, in validate raise CommandError&lt;/span&gt;&lt;/pre&gt;&lt;pre class="exception_value" style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;("One or more models did not validate:\n%s" % error_text)&lt;/span&gt;&lt;/pre&gt;&lt;pre class="exception_value" style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;django.core.management.base.CommandError:&lt;/span&gt;&lt;/pre&gt;&lt;pre class="exception_value" style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;One or more models did not&amp;nbsp;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;validate:&lt;/span&gt;&lt;/pre&gt;&lt;pre class="exception_value" style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;ukieri.participants: "logo": To use ImageFields,&amp;nbsp;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="exception_value" style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;you need to install the Python Imaging Library. &lt;/span&gt;&lt;/pre&gt;&lt;pre class="exception_value" style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="exception_value" style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"&gt;Need to Install Python Imaging Library in server &lt;/span&gt;&lt;/pre&gt;&lt;pre class="exception_value" style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"&gt;Link for Download :&lt;a href="http://www.pythonware.com/products/pil/"&gt;http://www.pythonware.com/products/pil/&lt;/a&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"&gt;Second Problem is&amp;nbsp;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"&gt;&amp;nbsp;when i use {{ object.file.url }} in templates&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"&gt;Error in template is :&lt;/span&gt;&lt;/div&gt;&lt;h1&gt;&lt;span class="Apple-style-span" style="font-weight: normal;"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;TemplateSyntaxError at /file/&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/h1&gt;&lt;pre class="exception_value"&gt;Caught ValueError while rendering: The 'file' attribute has&lt;/pre&gt;&lt;pre class="exception_value"&gt;no file associated with it.&lt;/pre&gt;&lt;pre class="exception_value"&gt;&lt;/pre&gt;&lt;pre class="exception_value"&gt;&lt;span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"&gt;The problem is solve to use IF statments in template :-&lt;/span&gt;&lt;/pre&gt;&lt;pre class="exception_value"&gt;&lt;span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"&gt;For example :-&lt;/span&gt;&lt;/pre&gt;&lt;pre class="exception_value"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;{% if object.file %}&amp;nbsp;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="exception_value"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;     &amp;lt;img src="{{ object.file.url }}" /&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="exception_value"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;{% endif %} &lt;/span&gt;&lt;/pre&gt;&lt;pre class="exception_value"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/pre&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1497521753902285776-6195367828231735637?l=jagdeepmalhi.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jagdeepmalhi.blogspot.com/feeds/6195367828231735637/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://jagdeepmalhi.blogspot.com/2010/09/django-filefield-or-imagefield.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1497521753902285776/posts/default/6195367828231735637'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1497521753902285776/posts/default/6195367828231735637'/><link rel='alternate' type='text/html' href='http://jagdeepmalhi.blogspot.com/2010/09/django-filefield-or-imagefield.html' title='Django : FileField() or  ImageField()'/><author><name>jagdeepsinghmalhi</name><uri>http://www.blogger.com/profile/08521786673136153319</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='26' src='http://1.bp.blogspot.com/_cKWqnDTAg-4/StdboO4vVMI/AAAAAAAAAAk/zqhdKK1K8vQ/S220/Photo%24072.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1497521753902285776.post-8823344657068413992</id><published>2010-09-04T22:24:00.000+05:30</published><updated>2010-09-04T22:24:22.265+05:30</updated><title type='text'>Django application : Contact form</title><content type='html'>&lt;h1 class="western"&gt;&lt;span class="Apple-style-span" style="font-size: medium; font-weight: normal;"&gt;Make the Contact form in django and also mail is send to admin .&lt;/span&gt;&lt;/h1&gt;&lt;b&gt;forms.py&lt;/b&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;from django import forms &lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt; class  ContactForm(forms.Form): &lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;    subject = forms.CharField(max_length=100) &lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;    email = forms.EmailField(required=False, label='Your e-mail address') &lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;    message = forms.CharField(widget=forms.Textarea) &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;View.py&lt;/b&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;from django.core.mail import send_mail &lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;from django.http import HttpResponseRedirect &lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;from django.shortcuts import render_to_response &lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;from mysite.contact.forms import * &lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;from django.template import RequestContext &lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;from django.core.urlresolvers import reverse&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;a name='more'&gt;&lt;/a&gt; &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;def contact(request): &lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;    if request.method == 'POST': &lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;        form = ContactForm(request.POST) &lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;        if form.is_valid(): &lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;            cd = form.cleaned_data &lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;            send_mail( &lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;                cd['subject'], &lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;                cd['message'], &lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;                cd.get('email', 'noreply@example.com'), &lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;                ['singh.malhi22@gmail.com'], &lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;            ) &lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;            return render_to_response('contact/thanks.html', {'form': form}, context_instance=RequestContext(request)) &lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;    else: &lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;        form = ContactForm() &lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;    return render_to_response('contact/contact.html', {'form': form}, context_instance=RequestContext(request)) &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Template used :&lt;/b&gt;&lt;br /&gt;&lt;b&gt;output.html&lt;/b&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;lt;html&amp;gt; &lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;lt;head&amp;gt; &lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;    &amp;lt;title&amp;gt;Contact us&amp;lt;/title&amp;gt; &lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;lt;/head&amp;gt; &lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;lt;body&amp;gt; &lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;lt;link rel="stylesheet" type="text/css" href="/media/css/base.css" /&amp;gt; &lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;    &amp;lt;h1&amp;gt;Contact us&amp;lt;/h1&amp;gt; &lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;lt;br&amp;gt; &lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;    {% if form.errors %} &lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;        &amp;lt;p style="color: red;"&amp;gt; &lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;            Please correct the error{{ form.errors|pluralize }} below. &lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;        &amp;lt;/p&amp;gt; &lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;    {% endif %} &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;    &amp;lt;form action="" method="post"&amp;gt; &lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt; {% csrf_token %} &lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;        &amp;lt;table&amp;gt; &lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;            {{ form.as_table }} &lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;        &amp;lt;/table&amp;gt; &lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;        &amp;lt;input type="submit" value="Submit"&amp;gt; &lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;    &amp;lt;/form&amp;gt; &lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;lt;/body&amp;gt; &lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;lt;/html&amp;gt; &lt;/span&gt;&lt;br /&gt;&lt;b&gt;thanks.html&lt;/b&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;lt;html&amp;gt; &lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;lt;head&amp;gt; &lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;    &amp;lt;title&amp;gt;Thanks&amp;lt;/title&amp;gt; &lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;lt;/head&amp;gt; &lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;lt;link rel="stylesheet" type="text/css" href="/media/css/base.css" /&amp;gt; &lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;lt;body&amp;gt; &lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt; &amp;lt;h1&amp;gt;Thanks&amp;lt;/h1&amp;gt; &lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;lt;br&amp;gt; &lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;lt;h3&amp;gt; &lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;You are in safe hands&amp;lt;/h3&amp;gt; &lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;lt;/body&amp;gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1497521753902285776-8823344657068413992?l=jagdeepmalhi.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jagdeepmalhi.blogspot.com/feeds/8823344657068413992/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://jagdeepmalhi.blogspot.com/2010/09/django-application-contact-form.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1497521753902285776/posts/default/8823344657068413992'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1497521753902285776/posts/default/8823344657068413992'/><link rel='alternate' type='text/html' href='http://jagdeepmalhi.blogspot.com/2010/09/django-application-contact-form.html' title='Django application : Contact form'/><author><name>jagdeepsinghmalhi</name><uri>http://www.blogger.com/profile/08521786673136153319</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='26' src='http://1.bp.blogspot.com/_cKWqnDTAg-4/StdboO4vVMI/AAAAAAAAAAk/zqhdKK1K8vQ/S220/Photo%24072.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1497521753902285776.post-4521562600908973234</id><published>2010-09-04T22:15:00.001+05:30</published><updated>2010-09-04T22:16:09.032+05:30</updated><title type='text'>Django application : Add two number using forms</title><content type='html'>&lt;div style="font-weight: normal; margin-bottom: 0cm;"&gt;In Django its very simple to use the Django forms and create a very simple application using django forms.  &lt;/div&gt;&lt;div style="font-weight: normal; margin-bottom: 0cm;"&gt;&lt;b&gt;Example:&lt;/b&gt; Add to number  using Djnago forms  &lt;/div&gt;&lt;div style="margin-bottom: 0cm;"&gt;&lt;b&gt;forms.py&lt;/b&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0cm;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;from django import forms &lt;/span&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0cm;"&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0cm;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;class Output(forms.Form): &lt;/span&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0cm;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;    input1 = forms.FloatField() &lt;/span&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0cm;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;    input2 = forms.FloatField() &lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;a name='more'&gt;&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0cm;"&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0cm;"&gt;&lt;b&gt; View.py &lt;/b&gt; &lt;/div&gt;&lt;div style="margin-bottom: 0cm;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;from django.http import HttpResponseRedirect &lt;/span&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0cm;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;from django.shortcuts import render_to_response &lt;/span&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0cm;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;from mysite.add.forms import * &lt;/span&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0cm;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;from django.template import RequestContext &lt;/span&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0cm;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;from django.core.urlresolvers import reverse &lt;/span&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0cm;"&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0cm;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;def add(request): &lt;/span&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0cm;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;    if request.method == 'POST': &lt;/span&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0cm;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;        form = Output(request.POST) &lt;/span&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0cm;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;        if form.is_valid(): &lt;/span&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0cm;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;            cd = form.cleaned_data &lt;/span&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0cm;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;            input1 = cd['input1'] &lt;/span&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0cm;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;            input2 = cd['input2'] &lt;/span&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0cm;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;            output = input1 + input2 &lt;/span&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0cm;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;            return render_to_response('add/output.html', {'form':form, 'input1': input1, 'input2':input2, 'output':output}, context_instance=RequestContext(request)) &lt;/span&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0cm;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;    else: &lt;/span&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0cm;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;        form = Output() &lt;/span&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0cm;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;    return render_to_response('add/add.html', {'form': form}, context_instance=RequestContext(request))&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0cm;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0cm;"&gt;&lt;b&gt;Templates used &lt;/b&gt; &lt;/div&gt;&lt;div style="margin-bottom: 0cm;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0cm;"&gt;&lt;b&gt;add.html&lt;/b&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0cm;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;lt;html&amp;gt; &lt;/span&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0cm;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;lt;head&amp;gt; &lt;/span&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0cm;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;    &amp;lt;title&amp;gt;Add Numbers&amp;lt;/title&amp;gt; &lt;/span&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0cm;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;lt;/head&amp;gt; &lt;/span&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0cm;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;lt;body&amp;gt; &lt;/span&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0cm;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;lt;link rel="stylesheet" type="text/css" href="/media/css/base.css" /&amp;gt; &lt;/span&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0cm;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;    &amp;lt;h1&amp;gt;Add Two Number Application &amp;lt;/h1&amp;gt; &lt;/span&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0cm;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;lt;br&amp;gt; &lt;/span&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0cm;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;    {% if form.errors %} &lt;/span&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0cm;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;        &amp;lt;p style="color: red;"&amp;gt; &lt;/span&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0cm;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;            Please correct the error{{ form.errors|pluralize }} below. &lt;/span&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0cm;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;        &amp;lt;/p&amp;gt; &lt;/span&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0cm;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;    {% endif %} &lt;/span&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0cm;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;    &amp;lt;h2&amp;gt; Fill Data &lt;/span&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0cm;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;    &amp;lt;form action="" method="post"&amp;gt; &lt;/span&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0cm;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;        {% csrf_token %} &lt;/span&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0cm;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;        &amp;lt;table&amp;gt; &lt;/span&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0cm;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;            {{ form.as_table }} &lt;/span&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0cm;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;        &amp;lt;/table&amp;gt; &lt;/span&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0cm;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;        &amp;lt;input type="submit" value="Submit"&amp;gt; &lt;/span&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0cm;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;    &amp;lt;/form&amp;gt; &lt;/span&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0cm;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;lt;/body&amp;gt; &lt;/span&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0cm;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;lt;/html&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0cm;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0cm;"&gt;&lt;b&gt;Output.html&lt;/b&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0cm;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;lt;html&amp;gt; &lt;/span&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0cm;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;lt;head&amp;gt; &lt;/span&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0cm;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;    &amp;lt;title&amp;gt;Thanks&amp;lt;/title&amp;gt; &lt;/span&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0cm;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;lt;/head&amp;gt; &lt;/span&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0cm;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;lt;link rel="stylesheet" type="text/css" href="http://arce.sarovar.org/css/rai.css" /&amp;gt; &lt;/span&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0cm;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;lt;body&amp;gt; &lt;/span&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0cm;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt; &amp;lt;h1&amp;gt;Thanks&amp;lt;/h1&amp;gt; &lt;/span&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0cm;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;lt;ul&amp;gt; &lt;/span&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0cm;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;lt;li&amp;gt;First Value = {{input1}} &lt;/span&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0cm;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;lt;li&amp;gt;Second Value = {{input2}} &lt;/span&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0cm;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;lt;li&amp;gt; Output = {{output}} &lt;/span&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0cm;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;lt;/body&amp;gt; &amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1497521753902285776-4521562600908973234?l=jagdeepmalhi.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jagdeepmalhi.blogspot.com/feeds/4521562600908973234/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://jagdeepmalhi.blogspot.com/2010/09/django-application-add-two-number-using.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1497521753902285776/posts/default/4521562600908973234'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1497521753902285776/posts/default/4521562600908973234'/><link rel='alternate' type='text/html' href='http://jagdeepmalhi.blogspot.com/2010/09/django-application-add-two-number-using.html' title='Django application : Add two number using forms'/><author><name>jagdeepsinghmalhi</name><uri>http://www.blogger.com/profile/08521786673136153319</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='26' src='http://1.bp.blogspot.com/_cKWqnDTAg-4/StdboO4vVMI/AAAAAAAAAAk/zqhdKK1K8vQ/S220/Photo%24072.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1497521753902285776.post-2720754936628359229</id><published>2010-09-04T11:57:00.000+05:30</published><updated>2010-09-04T11:57:31.028+05:30</updated><title type='text'>Script :Find and Replace word from files.</title><content type='html'>&lt;h1 class="western"&gt;&lt;span class="Apple-style-span" style="font-size: medium; font-weight: normal;"&gt;Script for Replace the One word with another word from all files place in present directory.&lt;/span&gt;&lt;/h1&gt;&lt;div style="margin-bottom: 0cm;"&gt;And also take backup of old files.&lt;/div&gt;&lt;div style="margin-bottom: 0cm;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0cm;"&gt;Step to use :&lt;/div&gt;&lt;div style="margin-bottom: 0cm;"&gt;&amp;gt; Copy the below script in file&lt;/div&gt;&lt;div style="margin-bottom: 0cm;"&gt;&amp;gt; Change the permission of file $chmod u+x filename&lt;/div&gt;&lt;div style="margin-bottom: 0cm;"&gt;&amp;gt; Run this ./filename&lt;/div&gt;&lt;div style="margin-bottom: 0cm;"&gt;&amp;gt; &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;FindWord&lt;/span&gt; is word to find and replace With &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;ReplaceWord&lt;/span&gt; &lt;/div&gt;&lt;div style="margin-bottom: 0cm;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;{&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0cm;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;for fl in *.php; do &lt;/span&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0cm;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;mv $fl $fl.old &lt;/span&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0cm;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;sed 's/FindWord::/ReplaceWord::/g' $fl.old &amp;gt; $fl &lt;/span&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0cm;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;done&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0cm;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;}&lt;/span&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1497521753902285776-2720754936628359229?l=jagdeepmalhi.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jagdeepmalhi.blogspot.com/feeds/2720754936628359229/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://jagdeepmalhi.blogspot.com/2010/09/script-find-and-replace-word-from-files.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1497521753902285776/posts/default/2720754936628359229'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1497521753902285776/posts/default/2720754936628359229'/><link rel='alternate' type='text/html' href='http://jagdeepmalhi.blogspot.com/2010/09/script-find-and-replace-word-from-files.html' title='Script :Find and Replace word from files.'/><author><name>jagdeepsinghmalhi</name><uri>http://www.blogger.com/profile/08521786673136153319</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='26' src='http://1.bp.blogspot.com/_cKWqnDTAg-4/StdboO4vVMI/AAAAAAAAAAk/zqhdKK1K8vQ/S220/Photo%24072.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1497521753902285776.post-7405515670201413904</id><published>2010-08-28T22:01:00.005+05:30</published><updated>2010-09-04T22:38:55.406+05:30</updated><title type='text'>Django Application : Create blog</title><content type='html'>&lt;h1&gt;Django : A Simple Blog Example&lt;/h1&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;First Create&amp;nbsp;application in Django project directory&lt;/div&gt;&lt;div&gt;#&lt;span class="Apple-style-span" style="font-family: monospace; white-space: pre;"&gt;python manage.py startapp blog&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: monospace; white-space: pre;"&gt;&lt;/span&gt;&amp;nbsp;Edit your setting.py file and add appilcation code&amp;nbsp;&lt;/div&gt;&lt;div&gt;For example :-&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;INSTALLED_APPS = (&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;'django.contrib.auth',&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;'django.contrib.contenttypes',&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;'django.contrib.sessions',&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;'django.contrib.sites',&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;'django.contrib.messages',&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;'mysite.blog', &amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;# Uncomment the next line to enable the admin:&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;'django.contrib.admin',&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;)&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;also add &amp;nbsp;Email host to send email.&lt;/div&gt;&lt;div&gt;by default its for locahost, but if your host have not configure EMAIL_HOST then you add this in &lt;b&gt;settings.py&lt;/b&gt;&amp;nbsp;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;#EMAIL_HOST = "hostname.com"&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;Edit Urls in url.py main file in &amp;nbsp;project Directory.&lt;/div&gt;&lt;div&gt;&lt;b&gt;Urls.py&amp;nbsp;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;from django.conf.urls.defaults import *&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;from django.contrib import admin&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;admin.autodiscover()&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;urlpatterns = patterns('',&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;(r'^admin/', include(admin.site.urls)),&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;(r'^blog/', include('mysite.blog.urls')),&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;)&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;a name='more'&gt;&lt;/a&gt;&lt;/div&gt;&lt;div&gt;Edit model.py file in blog directory&lt;/div&gt;&lt;div&gt;&lt;b&gt;Model.py&lt;/b&gt;&amp;nbsp;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;from django.db import models&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;from django.contrib.auth.models import User&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;from django.contrib import admin&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;from django.core.mail import send_mail&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;class Post(models.Model):&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;title = models.CharField(max_length=60)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;body = models.TextField()&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;created = models.DateTimeField(auto_now_add=True)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;def __unicode__(self):&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;return self.title&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;class Comment(models.Model):&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;created = models.DateTimeField(auto_now_add=True)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;author = models.CharField(max_length=60)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;body = models.TextField()&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;post = models.ForeignKey(Post)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;def __unicode__(self):&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;return unicode("%s: %s" % (self.post, self.body[:60]))&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;def save(self, *args, **kwargs):&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;"""Email when a comment is added."""&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;if "notify" in kwargs and kwargs["notify"] == True:&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;message = "Comment was was added to '%s' by '%s': \n\n%s" % (self.post, self.author,&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; self.body)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;from_addr = "no-reply@example.com"&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;recipient_list = ["jagdeepmalhi@gndec.ac.in"]&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;send_mail( "New comment added", message, from_addr, recipient_list)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;if "notify" in kwargs: del kwargs["notify"]&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;super(Comment, self).save(*args, **kwargs)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;&amp;nbsp;Create one more file urls.py file in your blog directory and edit&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;&lt;b&gt;Urls.py&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;from django.conf.urls.defaults import *&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;div&gt;from mysite.blog.models import *&lt;/div&gt;&lt;div&gt;urlpatterns = patterns('mysite.blog.views',&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp; (r"^(\d+)/$", "post"),&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp; (r"^add_comment/(\d+)/$", "add_comment"),&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp; (r"^delete_comment/(\d+)/$", "delete_comment"),&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp; (r"^delete_comment/$", "delete_comment"),&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp; (r"^month/(\d+)/(\d+)/$", "month"),&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp; (r"", "main"),&lt;/div&gt;&lt;div&gt;)&lt;/div&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;Create the admin.py file in blog directory and edit file for admin Interface.&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;&lt;b&gt;Admin.py&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;from mysite.blog.models import *&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;from django.contrib import admin&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;class PostAdmin(admin.ModelAdmin):&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;search_fields = ['title']&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;list_display = ("title", "created")&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;list_filter&lt;/span&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;= &amp;nbsp;['title']&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;class CommentAdmin(admin.ModelAdmin):&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;list_display = ["post", "author", "created"]&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;list_filter&lt;/span&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;= &amp;nbsp;['created']&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;admin.site.register(Post, PostAdmin)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;admin.site.register(Comment, CommentAdmin)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Edit the Views.py file for create the user view.&lt;/div&gt;&lt;div&gt;&lt;b&gt;Views.py&lt;/b&gt;&lt;br /&gt;# Create your views here.&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;import time&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;from django.http import HttpResponseRedirect, HttpResponse&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;from django.shortcuts import get_object_or_404, render_to_response&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;from django.contrib.auth.decorators import login_required&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;from django.core.context_processors import csrf&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;from django.core.paginator import Paginator, InvalidPage, EmptyPage&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;from mysite.blog.models import *&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;from django.forms import ModelForm&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;class CommentForm(ModelForm):&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;class Meta:&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;model = Comment&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;exclude = ["post"]&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;def post(request, pk):&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;"""Single post with comments and a comment form."""&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;post = Post.objects.get(pk=pk)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;comments = Comment.objects.filter(post=post)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;d = dict(post=post, comments=comments, form=CommentForm(), user=request.user)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;d.update(csrf(request))&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;return render_to_response("blog/post.html", d)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;def delete_comment(request, pk=None):&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;"""Delete comment(s) with primary key `pk` or with pks in POST."""&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;if request.user.is_staff:&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;if not pk: pklst = request.POST.getlist("delete")&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;else: pklst = [pk]&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;for pk in pklst:&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Comment.objects.filter(pk=pk).delete()&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;return HttpResponseRedirect(request.META["HTTP_REFERER"])&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;def add_comment(request, pk):&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;"""Add a new comment."""&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;p = request.POST&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;if p.has_key("body") and p["body"]:&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;author = "Anonymous"&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;if p["author"]: author = p["author"]&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;comment = Comment(post=Post.objects.get(pk=pk))&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;# save comment form&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;cf = CommentForm(p, instance=comment)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;cf.fields["author"].required = False&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;comment = cf.save(commit=False)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;# save comment instance&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;comment.author = author&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;notify = True&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;if request.user.username == "ak": notify = False&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;comment.save(notify=notify)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;return HttpResponseRedirect("/django/blog/%s/" % pk)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;def mkmonth_lst():&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;"""Make a list of months to show archive links."""&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;if not Post.objects.count(): return []&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;# set up vars&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;year, month = time.localtime()[:2]&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;first = Post.objects.order_by("created")[0]&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;fyear = first.created.year&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;fmonth = first.created.month&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;months = []&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;mnames = "January February March April May June July August September October November December"&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;mnames = mnames.split()&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;# loop over years and months&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;for y in range(year, fyear-1, -1):&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;start, end = 11, -1&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;if y == year: start = month&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;if y == fyear: end = fmonth-1&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;for m in range(start, end, -1):&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;months.append((y, m, mnames[m]))&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;return months&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;def month(request, year, month):&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;"""Monthly archive."""&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;posts = Post.objects.filter(created__year=year, created__month=month)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;for post in posts:&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;post.num_comments = Comment.objects.filter(post=post).count()&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;return render_to_response("blog/list.html", dict(post_list=posts, user=request.user,&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;months=mkmonth_lst(), archive=True))&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;def main(request):&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;"""Main listing."""&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;posts = Post.objects.all().order_by("-created")&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;paginator = Paginator(posts, 2)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;try: page = int(request.GET.get("page", '1'))&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;except ValueError: page = 1&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;try:&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;posts = paginator.page(page)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;except (InvalidPage, EmptyPage):&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;posts = paginator.page(paginator.num_pages)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;for post in posts.object_list:&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;post.num_comments = Comment.objects.filter(post=post).count()&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;return render_to_response("blog/list.html", dict(posts=posts, user=request.user,&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;post_list=posts.object_list, months=mkmonth_lst()))&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Now Create the Templates for User and place these file in your templates Directory.&lt;/div&gt;&lt;div&gt;&lt;b&gt;list.html&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;{% extends "blog/bbase.html" %}&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;{% block sidebar %}&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;lt;style type="text/css"&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;#sidebar { float: right; border: 1px dotted #ccc; padding: 4px; }&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;a { margin-left: 15px; }&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;lt;/style&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;lt;div id="sidebar"&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Monthly Archive&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;p&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;{% for month in months %}&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;{% ifchanged month.0 %} {{ month.0 }} &amp;lt;br /&amp;gt; {% endifchanged %}&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;a href="/django/blog/month/{{ month.0 }}/{{ month.1 }}/"&amp;gt;{{ month.2 }}&amp;lt;/a&amp;gt; &amp;lt;br /&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;{% endfor %}&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;/p&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;lt;/div&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;{% endblock %}&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;{% block content %}&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;lt;style type="text/css"&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;.main { margin-left: 25px; margin-top: 30px; }&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;.time { font-size: 0.8em; margin-top: 2px; }&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;.body { font-size: 1.1em; margin-top: 2px; }&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;.commentlink { text-align: right; }&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;.step-links a { font-size: 0.89em; }&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;.title {&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;font-size: 1.4em; margin-top: 20px; border-bottom: 1px solid #ccc;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;padding-left: 4px;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;.messages { margin-left: 20px; }&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;lt;/style&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;lt;div class="main"&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;!-- Messages &amp;nbsp;--&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;{% if messages %}&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;ul class="messages"&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;{% for message in messages %}&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;li{% if message.tags %} class="{{ message.tags }}"{% endif %}&amp;gt;{{ message }}&amp;lt;/li&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;{% endfor %}&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;/ul&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;{% endif %}&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;!-- Posts &amp;nbsp;--&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;ul&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;{% for post in post_list %}&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;div class="title"&amp;gt;{{ post.title }}&amp;lt;/div&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;ul&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;div class="time"&amp;gt;{{ post.created }}&amp;lt;/div&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;div class="body"&amp;gt;{{ post.body|linebreaks }}&amp;lt;/div&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;div class="commentlink"&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;a href="/django/blog/{{ post.pk }}/"&amp;gt;Comments ({{ post.num_comments }})&amp;lt;/a&amp;gt;&amp;lt;/div&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;/ul&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;{% endfor %}&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;/ul&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;!-- Next/Prev page links &amp;nbsp;--&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;{% if not archive and posts.object_list and posts.paginator.num_pages &amp;gt; 1 %}&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;div class="pagination" style="margin-top: 20px; margin-left: -20px; "&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;span class="step-links"&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;{% if posts.has_previous %}&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;a href= "?page={{ posts.previous_page_number }}"&amp;gt;newer entries &amp;amp;lt;&amp;amp;lt; &amp;lt;/a&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;{% endif %}&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;span class="current"&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;amp;nbsp;Page {{ posts.number }} of {{ posts.paginator.num_pages }}&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;/span&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;{% if posts.has_next %}&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;a href="?page={{ posts.next_page_number }}"&amp;gt; &amp;amp;gt;&amp;amp;gt; older entries&amp;lt;/a&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;{% endif %}&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;/span&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;/div&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;{% endif %}&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;lt;/div&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;{% endblock %}&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;&lt;b&gt;bbase.html&lt;/b&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;lt;?xml version="1.0" encoding="UTF-8"?&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;lt;html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;lt;head&amp;gt; &amp;lt;title&amp;gt;{% block title %}Blog{% endblock %}&amp;lt;/title&amp;gt; &amp;lt;/head&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;lt;body&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;lt;div id="sidebar"&amp;gt; {% block sidebar %} {% endblock %} &amp;lt;/div&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;lt;div id="container"&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;div id="menu"&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;{% block nav-global %}&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;!-- MENU --&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;h3&amp;gt;Jagdeep Singh&amp;lt;/h3&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;{% if user.is_staff %}&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;  &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;lt;a href="/django/admin/"&amp;gt;Admin&amp;lt;/a&amp;gt; &amp;lt;a href="/django/admin/blog/post/add/"&amp;gt;Add post&amp;lt;/a&amp;gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;{% endif %}&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt; &lt;/span&gt; &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;{% endblock %}&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;/div&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;div id="content"&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;{% block content %}{% endblock %}&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;/div&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;lt;/div&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt; &lt;/span&gt; &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;lt;/body&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;lt;/html&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;&lt;div&gt;&lt;/div&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;div&gt;&lt;div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;&lt;b&gt;post.html&lt;/b&gt;&amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;{% extends "blog/bbase.html" %}&lt;br /&gt;&lt;br /&gt;{% block content %}&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;lt;style type="text/css"&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;.main { margin-left: 25px; margin-top: 30px; }&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;.time { font-size: 0.8em; margin-top: 2px; }&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;.comment { border: 1px solid #eee; padding: 4px; margin-bottom: 12px; }&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;.body { font-size: 1.1em; margin-top: 2px; }&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;.commentlink { text-align: right; }&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;.step-links a { font-size: 0.89em; }&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;.title {&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;font-size: 1.4em; margin-top: 20px; border-bottom: 1px solid #ccc;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;padding-left: 4px;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;.messages { margin-left: 20px; }&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;#id_body { width: 500px; height: 250px; }&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;#addc {&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;width: 508px; background: #f5f5f5; padding: 3px; padding-bottom: 8px;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;border-bottom: 1px dotted #aaa; }&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;#cform { background: #f5f5f5; width: 506px; padding: 4px; padding-bottom: 0px; }&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;#submit { text-align: right; margin-right: 50px; width: 500px; margin-top: -5px; }&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;ul { margin-bottom: 30px; }&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;lt;/style&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;lt;div class="main"&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;!-- Messages &amp;nbsp;--&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;{% if messages %}&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;ul class="messages"&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;{% for message in messages %}&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;li{% if message.tags %} class="{{ message.tags }}"{% endif %}&amp;gt;{{ message }}&amp;lt;/li&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;{% endfor %}&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;/ul&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;{% endif %}&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;!-- Post &amp;nbsp;--&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;ul&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;div class="title"&amp;gt;{{ post.title }}&amp;lt;/div&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;ul&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;div class="time"&amp;gt;{{ post.created }}&amp;lt;/div&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;div class="body"&amp;gt;{{ post.body }}&amp;lt;/div&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;/ul&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;!-- Comments &amp;nbsp;--&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;{% if comments %}&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;p&amp;gt;Comments:&amp;lt;/p&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;{% endif %}&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;form action="/django/blog/delete_comment/" method="POST"&amp;gt;{% csrf_token %}&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;{% for comment in comments %}&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;div class="comment"&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;div class="time"&amp;gt;{{ comment.created }} | {{ comment.author }}&amp;lt;/div&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;div class="body"&amp;gt;{{ comment.body|linebreaks }}&amp;lt;/div&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;{% if user.is_staff %}&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;input type="checkbox" name="delete" value="{{ comment.pk }}"&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;a href="/django/blog/delete_comment/{{ comment.pk }}/"&amp;gt;delete&amp;lt;/a&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;{% endif %}&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;/div&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;{% endfor %}&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;{% if user.is_staff and comments %}&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;p&amp;gt;&amp;lt;input type="submit" value="Delete all selected"&amp;gt;&amp;lt;/p&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;br /&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;{% endif %}&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;/form&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;div id="addc"&amp;gt;Add a comment&amp;lt;/div&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;!-- Comment form &amp;nbsp;--&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;form action="/django/blog/add_comment/{{ post.pk }}/" method="POST"&amp;gt;{% csrf_token %}&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;div id="cform"&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Name: {{ form.author }}&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;p&amp;gt;{{ form.body|linebreaks }}&amp;lt;/p&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;/div&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;div id="submit"&amp;gt;&amp;lt;input type="submit" value="Submit"&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;/form&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;/ul&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;lt;/div&amp;gt;&lt;br /&gt;&lt;br /&gt;{% endblock %}&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;Now enjoy your &amp;nbsp;Blog on Django.&lt;/span&gt;&lt;/div&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/span&gt;&lt;/div&gt;&lt;/span&gt;&lt;/div&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1497521753902285776-7405515670201413904?l=jagdeepmalhi.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jagdeepmalhi.blogspot.com/feeds/7405515670201413904/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://jagdeepmalhi.blogspot.com/2010/08/django-create-blog-example.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1497521753902285776/posts/default/7405515670201413904'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1497521753902285776/posts/default/7405515670201413904'/><link rel='alternate' type='text/html' href='http://jagdeepmalhi.blogspot.com/2010/08/django-create-blog-example.html' title='Django Application : Create blog'/><author><name>jagdeepsinghmalhi</name><uri>http://www.blogger.com/profile/08521786673136153319</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='26' src='http://1.bp.blogspot.com/_cKWqnDTAg-4/StdboO4vVMI/AAAAAAAAAAk/zqhdKK1K8vQ/S220/Photo%24072.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1497521753902285776.post-2192503409015318775</id><published>2010-08-14T10:42:00.002+05:30</published><updated>2010-08-24T12:35:08.250+05:30</updated><title type='text'>Automation Project is approved : Sourceforge.org And  Sarovar.org</title><content type='html'>&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;b&gt;&lt;span class="Apple-style-span" style="font-size: x-large;"&gt;&lt;span class="Apple-style-span" style="font-size: medium; font-weight: normal;"&gt;Project registration for Automation has been approved.&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;&lt;span class="Apple-style-span" style="font-size: x-large;"&gt;Sarovar&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;links:-&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;http://sarovar.org/projects/automation/&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;http://automation.sarovar.org/&lt;br /&gt;&lt;b&gt;&lt;span class="Apple-style-span" style="font-size: x-large;"&gt;Sourceforge&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;links:-&lt;br /&gt;http://automations.sourceforge.net/&lt;br /&gt;http://sourceforge.net/projects/automations/&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1497521753902285776-2192503409015318775?l=jagdeepmalhi.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jagdeepmalhi.blogspot.com/feeds/2192503409015318775/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://jagdeepmalhi.blogspot.com/2010/08/office-automation-project-is-approved.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1497521753902285776/posts/default/2192503409015318775'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1497521753902285776/posts/default/2192503409015318775'/><link rel='alternate' type='text/html' href='http://jagdeepmalhi.blogspot.com/2010/08/office-automation-project-is-approved.html' title='Automation Project is approved : Sourceforge.org And  Sarovar.org'/><author><name>jagdeepsinghmalhi</name><uri>http://www.blogger.com/profile/08521786673136153319</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='26' src='http://1.bp.blogspot.com/_cKWqnDTAg-4/StdboO4vVMI/AAAAAAAAAAk/zqhdKK1K8vQ/S220/Photo%24072.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1497521753902285776.post-1966536020935677764</id><published>2010-08-10T15:08:00.000+05:30</published><updated>2010-08-10T15:08:18.732+05:30</updated><title type='text'>Check  Django version</title><content type='html'>Start the interactive Python interpreter&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;gt;&amp;gt;&amp;gt; import django&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;gt;&amp;gt;&amp;gt; print django.VERSION&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1497521753902285776-1966536020935677764?l=jagdeepmalhi.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jagdeepmalhi.blogspot.com/feeds/1966536020935677764/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://jagdeepmalhi.blogspot.com/2010/08/check-django-version.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1497521753902285776/posts/default/1966536020935677764'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1497521753902285776/posts/default/1966536020935677764'/><link rel='alternate' type='text/html' href='http://jagdeepmalhi.blogspot.com/2010/08/check-django-version.html' title='Check  Django version'/><author><name>jagdeepsinghmalhi</name><uri>http://www.blogger.com/profile/08521786673136153319</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='26' src='http://1.bp.blogspot.com/_cKWqnDTAg-4/StdboO4vVMI/AAAAAAAAAAk/zqhdKK1K8vQ/S220/Photo%24072.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1497521753902285776.post-639147769693498423</id><published>2010-08-09T23:23:00.001+05:30</published><updated>2010-08-09T23:24:57.692+05:30</updated><title type='text'>Batch resize/Compress all images in a folder.</title><content type='html'>Make a new file (not as root):&lt;br /&gt;Run In Terminal&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: monospace; white-space: pre;"&gt;#gedit ~/.gnome2/nautilus-scripts/batch640x480&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: monospace; white-space: pre;"&gt; &lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="white-space: pre;"&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;and then Add&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: monospace;"&gt;&lt;span class="Apple-style-span" style="white-space: pre;"&gt;#!/bin/sh&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: monospace;"&gt;&lt;span class="Apple-style-span" style="white-space: pre;"&gt;# Use this script to batch resize all images in a folder.&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: monospace;"&gt;&lt;span class="Apple-style-span" style="white-space: pre;"&gt;# First open the folder and then use the script. &amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: monospace;"&gt;&lt;span class="Apple-style-span" style="white-space: pre;"&gt;for file in `ls -l`&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: monospace;"&gt;&lt;span class="Apple-style-span" style="white-space: pre;"&gt;do&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: monospace;"&gt;&lt;span class="Apple-style-span" style="white-space: pre;"&gt;name=`echo $file | cut -f1 -d.`&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: monospace;"&gt;&lt;span class="Apple-style-span" style="white-space: pre;"&gt;   convert -geometry 680x500 -quality 65 $file ${name}_680x500.jpg&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: monospace;"&gt;&lt;span class="Apple-style-span" style="white-space: pre;"&gt;done&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: monospace;"&gt;&lt;span class="Apple-style-span" style="white-space: pre;"&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: monospace;"&gt;&lt;span class="Apple-style-span" style="white-space: pre;"&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;Save this file and make this file executable:&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: monospace; white-space: pre;"&gt;#chmod +x ~/.gnome2/nautilus-scripts/batch640x480&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="white-space: pre;"&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;Go to the folder you'd like to &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="white-space: pre;"&gt;&lt;span class="highlight"&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;resize&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="white-space: pre;"&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;. Then rightclick and find the 'batch640x480' &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="white-space: pre;"&gt;&lt;span class="highlight"&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;script&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="white-space: pre;"&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;. &lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="white-space: pre;"&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;I use this &lt;/span&gt;&lt;span class="highlight"&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;script&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt; for resizing large amounts of photo's for a website&lt;/span&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1497521753902285776-639147769693498423?l=jagdeepmalhi.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jagdeepmalhi.blogspot.com/feeds/639147769693498423/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://jagdeepmalhi.blogspot.com/2010/08/batch-resizecompress-all-images-in.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1497521753902285776/posts/default/639147769693498423'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1497521753902285776/posts/default/639147769693498423'/><link rel='alternate' type='text/html' href='http://jagdeepmalhi.blogspot.com/2010/08/batch-resizecompress-all-images-in.html' title='Batch resize/Compress all images in a folder.'/><author><name>jagdeepsinghmalhi</name><uri>http://www.blogger.com/profile/08521786673136153319</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='26' src='http://1.bp.blogspot.com/_cKWqnDTAg-4/StdboO4vVMI/AAAAAAAAAAk/zqhdKK1K8vQ/S220/Photo%24072.jpg'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1497521753902285776.post-5737888265283786637</id><published>2010-08-08T16:59:00.000+05:30</published><updated>2010-08-08T16:59:59.308+05:30</updated><title type='text'>Drupal error : Function ereg() is deprecated</title><content type='html'>&lt;div class="content"&gt;Its is very simple to solve&lt;br /&gt;open file&amp;nbsp;includes/file.inc in drupal directory&lt;br /&gt;Goto line no in which this error is show &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;where you can see something like this&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt; elseif ($depth &amp;gt;= $min_depth &amp;amp;&amp;amp; ereg($mask, $file))&lt;/span&gt;&lt;br /&gt;Now add @ sign before ereg($mask, $file)&lt;br /&gt;copy below line past this line&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt; elseif ($depth &amp;gt;= $min_depth &amp;amp;&amp;amp; @ereg($mask, $file))&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Its works&lt;br /&gt;&lt;/div&gt;&lt;div class="links"&gt;&lt;span&gt;&lt;a href="http://drupal.org/user/login?destination=comment%2Freply%2F514334%23comment-form"&gt;&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1497521753902285776-5737888265283786637?l=jagdeepmalhi.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jagdeepmalhi.blogspot.com/feeds/5737888265283786637/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://jagdeepmalhi.blogspot.com/2010/08/drupal-error-function-ereg-is.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1497521753902285776/posts/default/5737888265283786637'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1497521753902285776/posts/default/5737888265283786637'/><link rel='alternate' type='text/html' href='http://jagdeepmalhi.blogspot.com/2010/08/drupal-error-function-ereg-is.html' title='Drupal error : Function ereg() is deprecated'/><author><name>jagdeepsinghmalhi</name><uri>http://www.blogger.com/profile/08521786673136153319</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='26' src='http://1.bp.blogspot.com/_cKWqnDTAg-4/StdboO4vVMI/AAAAAAAAAAk/zqhdKK1K8vQ/S220/Photo%24072.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1497521753902285776.post-7137822380360612301</id><published>2010-08-05T22:26:00.001+05:30</published><updated>2010-08-08T17:32:13.276+05:30</updated><title type='text'>Python : CMS</title><content type='html'>&lt;h1&gt;&lt;span class="Apple-style-span" style="font-size: x-large;"&gt;Plone&lt;/span&gt;&lt;/h1&gt;&lt;h2&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-weight: normal;"&gt;A powerful, flexible Content Management&amp;nbsp;solution that is easy to install, use and extend&lt;/span&gt;&lt;/span&gt;&lt;/h2&gt;Plone lets non-technical people create and maintain information for a  public website or an intranet using only a web browser. Plone is easy to  understand and  use — allowing users to be productive in just half an hour — yet  offers a wealth of community-developed add-ons and extensibility to  keep meeting your needs for years to come.&lt;br /&gt;&lt;br /&gt;&lt;a href="http://plone.org/"&gt;Click here for further detail&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: x-large;"&gt;&lt;b&gt;Skeletonz&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Content"&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Skeletonz is a new content management system (CMS) based on &lt;a href="http://python.org/" target="_blank"&gt;Python&lt;/a&gt;.  It differs from others by being simple, but yet very powerful and  extensible. If you need a simple system that you and your users are  going love then Skeletonz might be the solution you are looking for! The  system is open source and released under GNU &lt;a href="http://www.gnu.org/licenses/gpl.txt" target="_blank"&gt;GPL&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;&lt;a href="http://orangoo.com/skeletonz/"&gt;Click here for further detail&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;a name='more'&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: x-large;"&gt;&lt;b&gt;MediaCore Video CMS&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;MediaCore Video CMS is an open source media focused content management system. It features video &amp;amp; audio support, &lt;a class="nonexistent" href="http://wiki.python.org/moin/YouTube"&gt;YouTube&lt;/a&gt;  &amp;amp; Vimeo integration, podcasting, iTunes RSS generation,  user-submitted content, embedded media player, wysiwg edior, search, and  is highly customizable. There is both a front-end for users and a  back-end for administrators. It is built upon &lt;a href="http://wiki.python.org/moin/TurboGears"&gt;TurboGears&lt;/a&gt;, SQLAlchemy, MYSQL and runs with Apache, Fast_CGI or Mod_WSGI. &lt;br /&gt;&lt;br /&gt;&lt;a href="http://getmediacore.com/"&gt;Click here for more detail&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://getmediacore.com/"&gt;&lt;/a&gt;&lt;b&gt;&lt;span class="Apple-style-span" style="font-size: x-large;"&gt;PyLucid&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;PyLucid is a  lightweight CMS written in Python WSGI. No shell account is needed. To  run PyLucid you need a standard Web server with Python (at least v2.3),  CGI and mySQLdb.&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.pylucid.org/"&gt;More detail&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;&lt;a href="http://jagdeepmalhi.blogspot.com/2010/06/django-cms.html"&gt;&lt;span class="Apple-style-span" style="font-size: x-large;"&gt;Django - CMS&lt;/span&gt;&lt;/a&gt;&lt;/b&gt;&lt;br /&gt;&lt;h2&gt;&lt;/h2&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1497521753902285776-7137822380360612301?l=jagdeepmalhi.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jagdeepmalhi.blogspot.com/feeds/7137822380360612301/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://jagdeepmalhi.blogspot.com/2010/08/plone-cms.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1497521753902285776/posts/default/7137822380360612301'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1497521753902285776/posts/default/7137822380360612301'/><link rel='alternate' type='text/html' href='http://jagdeepmalhi.blogspot.com/2010/08/plone-cms.html' title='Python : CMS'/><author><name>jagdeepsinghmalhi</name><uri>http://www.blogger.com/profile/08521786673136153319</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='26' src='http://1.bp.blogspot.com/_cKWqnDTAg-4/StdboO4vVMI/AAAAAAAAAAk/zqhdKK1K8vQ/S220/Photo%24072.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1497521753902285776.post-2305243749219684952</id><published>2010-08-04T14:27:00.000+05:30</published><updated>2010-08-04T14:27:10.315+05:30</updated><title type='text'>Django : Auto-Generate  model.py file from PostgreSQL / MySQL / SQLite database</title><content type='html'>&lt;h3&gt;inspectdb&lt;/h3&gt;&lt;dl&gt;&lt;dt style="margin-bottom: 0.5cm;"&gt;&lt;a href="" name="django-admin-inspectdb"&gt;&lt;/a&gt;  &lt;tt class="western"&gt;django-admin.py inspectdb &lt;/tt&gt;  &lt;/dt&gt;&lt;/dl&gt;Introspects the database tables in the database pointed-to by the &lt;tt class="western"&gt;NAME&lt;/tt&gt; setting and outputs a Django model module (a &lt;tt class="western"&gt;models.py&lt;/tt&gt; file) to standard output.&lt;br /&gt;This feature is meant as a shortcut, not as definitive model generation. After you run it, you'll want to look over the generated models yourself to make customizations. In particular, you'll need to rearrange models' order, so that models that refer to other models are ordered properly.&lt;br /&gt;Primary keys are automatically introspected for PostgreSQL, MySQL and SQLite, in which case Django puts in the &lt;tt class="western"&gt;primary_key=True&lt;/tt&gt; where needed.&lt;br /&gt;&lt;tt class="western"&gt;inspectdb&lt;/tt&gt; works with PostgreSQL, MySQL and SQLite. Foreign-key detection only works in PostgreSQL and with certain types of MySQL tables.&lt;br /&gt;&lt;div style="margin-bottom: 0cm;"&gt;Example :&lt;/div&gt;&lt;div style="margin-bottom: 0cm;"&gt;Use command&lt;/div&gt;&lt;div style="margin-bottom: 0cm;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;#python manage.py  inspectdb &amp;gt;&amp;gt;Models.py  &lt;/span&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0cm;"&gt;this will automatically convert the django database into Models.py  file .&lt;/div&gt;&lt;div style="margin-bottom: 0cm;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1497521753902285776-2305243749219684952?l=jagdeepmalhi.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jagdeepmalhi.blogspot.com/feeds/2305243749219684952/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://jagdeepmalhi.blogspot.com/2010/08/django-auto-generate-modelpy-file-from.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1497521753902285776/posts/default/2305243749219684952'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1497521753902285776/posts/default/2305243749219684952'/><link rel='alternate' type='text/html' href='http://jagdeepmalhi.blogspot.com/2010/08/django-auto-generate-modelpy-file-from.html' title='Django : Auto-Generate  model.py file from PostgreSQL / MySQL / SQLite database'/><author><name>jagdeepsinghmalhi</name><uri>http://www.blogger.com/profile/08521786673136153319</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='26' src='http://1.bp.blogspot.com/_cKWqnDTAg-4/StdboO4vVMI/AAAAAAAAAAk/zqhdKK1K8vQ/S220/Photo%24072.jpg'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1497521753902285776.post-2806806819144570865</id><published>2010-07-31T21:51:00.001+05:30</published><updated>2010-08-08T17:25:56.256+05:30</updated><title type='text'>Python : Accesssing a MySQL Database</title><content type='html'>&lt;div style="margin-bottom: 0.5cm;"&gt;&lt;a href="http://www.blogger.com/post-edit.g?blogID=1497521753902285776&amp;amp;postID=2806806819144570865" name="IXT-8-231974"&gt;&lt;/a&gt;The &lt;tt&gt;MySQLdb&lt;/tt&gt; module makes this task extremely easy:  &lt;/div&gt;&lt;pre&gt;import MySQLdb&lt;br /&gt;&lt;br /&gt;# Create a connection object, then use it to create a cursor&lt;br /&gt;Con = MySQLdb.connect(host="127.0.0.1", port=3306, &lt;br /&gt;    user="joe", passwd="egf42", db="tst")&lt;br /&gt;Cursor = Con.cursor(  )&lt;br /&gt;&lt;br /&gt;# Execute an SQL string&lt;br /&gt;sql = "SELECT * FROM Users"&lt;br /&gt;Cursor.execute(sql)&lt;br /&gt;&lt;br /&gt;# Fetch all results from the cursor into a sequence and close the connection&lt;br /&gt;Results = Cursor.fetchall(  )&lt;br /&gt;Con.close(  )&lt;/pre&gt;&lt;pre&gt;&lt;/pre&gt;&lt;pre&gt;&lt;div style="margin-bottom: 0.5cm;"&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0.5cm;"&gt;&lt;/div&gt;&lt;span style="font-family: 'Times New Roman', serif;"&gt;Youcan get the &lt;/span&gt;&lt;tt&gt;&lt;span style="font-family: 'Times New Roman', serif;"&gt;MySQLdb &lt;/span&gt;&lt;/tt&gt;&lt;span style="font-family: 'Times New Roman', serif;"&gt;module from &lt;a href="http://sourceforge.net/projects/mysql-python" target="_blank"&gt;http://sourceforge.net/projects/mysql-python&lt;/a&gt;. It is a plain and&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Times New Roman', serif;"&gt;simple implementation of the Python DB API 2.0 that is suitable for all &lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Times New Roman', serif;"&gt; Python versions from 1.5.2 to&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Times New Roman', serif;"&gt;2.2.1 and MySQL Versions 3.22 to 4.0. &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: 'Times New Roman', serif;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: 'Times New Roman', serif;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: 'Times New Roman', serif;"&gt;&lt;a name='more'&gt;&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;&lt;a href="http://www.blogger.com/post-edit.g?blogID=1497521753902285776&amp;amp;postID=2806806819144570865" name="IXT-8-231975"&gt;&lt;/a&gt;&lt;span style="font-family: 'Times New Roman', serif;"&gt;As with all other Python DB API implementations, you start by importing the module and &lt;/span&gt;&lt;span style="font-family: 'Times New Roman', serif;"&gt;calling the&lt;/span&gt;&lt;br /&gt;&lt;tt&gt;&lt;span style="font-family: 'Times New Roman', serif;"&gt;connect &lt;/span&gt;&lt;/tt&gt;&lt;span style="font-family: 'Times New Roman', serif;"&gt;function with suitable parameters. The keyword parameters you can &lt;/span&gt;&lt;span style="font-family: 'Times New Roman', serif;"&gt;pass when calling&amp;nbsp;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: 'Times New Roman', serif;"&gt;&lt;/span&gt;&lt;tt&gt;&lt;span style="font-family: 'Times New Roman', serif;"&gt;connect&lt;/span&gt;&lt;/tt&gt;&lt;tt&gt;&lt;span style="font-family: 'Times New Roman', serif;"&gt; &lt;/span&gt;&lt;/tt&gt;&lt;span style="font-family: 'Times New Roman', serif;"&gt;depend on the database involved: &lt;/span&gt;&lt;tt&gt;&lt;span style="font-family: 'Times New Roman', serif;"&gt;host &lt;/span&gt;&lt;/tt&gt;&lt;span style="font-family: 'Times New Roman', serif;"&gt;(defaulting to the local host), &lt;/span&gt;&lt;tt&gt;&lt;span style="font-family: 'Times New Roman', serif;"&gt;user&lt;/span&gt;&lt;/tt&gt;&lt;span style="font-family: 'Times New Roman', serif;"&gt;, &lt;/span&gt;&lt;tt&gt;&lt;span style="font-family: 'Times New Roman', serif;"&gt;passwd &lt;/span&gt;&lt;/tt&gt;&lt;span style="font-family: 'Times New Roman', serif;"&gt;(password),&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: 'Times New Roman', serif;"&gt;and &lt;/span&gt;&lt;tt&gt;&lt;span style="font-family: 'Times New Roman', serif;"&gt;db &lt;/span&gt;&lt;/tt&gt;&lt;span style="font-family: 'Times New Roman', serif;"&gt;(name of the database) are typical. In the recipe, I explicitly pass &lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Times New Roman', serif;"&gt;the default local host's IP&amp;nbsp;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Times New Roman', serif;"&gt;address and the default MySQL port (3306) to show that you can specify &lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Times New Roman', serif;"&gt;parameters explicitly even&amp;nbsp;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Times New Roman', serif;"&gt;when you're passing their default values (e.g., to make your source code &lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Times New Roman', serif;"&gt;clearer and more readable&amp;nbsp;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Times New Roman', serif;"&gt;and maintainable). &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: 'Times New Roman', serif;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: 'Times New Roman', serif;"&gt;The &lt;/span&gt;&lt;tt&gt;&lt;span style="font-family: 'Times New Roman', serif;"&gt;connect &lt;/span&gt;&lt;/tt&gt;&lt;span style="font-family: 'Times New Roman', serif;"&gt;function returns a connection object, and you can proceed to call methods on this object&amp;nbsp;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: 'Times New Roman', serif;"&gt;until, when you are done, you call the &lt;/span&gt;&lt;tt&gt;&lt;span style="font-family: 'Times New Roman', serif;"&gt;close &lt;/span&gt;&lt;/tt&gt;&lt;span style="font-family: 'Times New Roman', serif;"&gt;method. The method you most often call on a connection&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: 'Times New Roman', serif;"&gt;object is &lt;/span&gt;&lt;tt&gt;&lt;span style="font-family: 'Times New Roman', serif;"&gt;cursor&lt;/span&gt;&lt;/tt&gt;&lt;span style="font-family: 'Times New Roman', serif;"&gt;, which returns a cursor object, which is what you use to send SQL commands to the&amp;nbsp;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: 'Times New Roman', serif;"&gt;database and fetch the commands' results. The underlying MySQL database engine does not in fact support&amp;nbsp;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: 'Times New Roman', serif;"&gt;SQL cursors, but that's no problem—the &lt;/span&gt;&lt;tt&gt;&lt;span style="font-family: 'Times New Roman', serif;"&gt;MySQLdb &lt;/span&gt;&lt;/tt&gt;&lt;span style="font-family: 'Times New Roman', serif;"&gt;module emulates them on your behalf quite transparently.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: 'Times New Roman', serif;"&gt;&lt;/span&gt;&lt;span style="font-family: 'Times New Roman', serif;"&gt;Once you have a &lt;/span&gt;&lt;tt&gt;&lt;span style="font-family: 'Times New Roman', serif;"&gt;cursor &lt;/span&gt;&lt;/tt&gt;&lt;span style="font-family: 'Times New Roman', serif;"&gt;object in hand, you can call methods on it. The recipe uses the &lt;/span&gt;&lt;tt&gt;&lt;span style="font-family: 'Times New Roman', serif;"&gt;execute &lt;/span&gt;&lt;/tt&gt;&lt;span style="font-family: 'Times New Roman', serif;"&gt;method to&amp;nbsp;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: 'Times New Roman', serif;"&gt;execute an SQL statement and the &lt;/span&gt;&lt;tt&gt;&lt;span style="font-family: 'Times New Roman', serif;"&gt;fetchall &lt;/span&gt;&lt;/tt&gt;&lt;span style="font-family: 'Times New Roman', serif;"&gt;method to obtain all results as a sequence of tuples—one tuple&amp;nbsp;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: 'Times New Roman', serif;"&gt;per row in the result. There are many refinements you can use, but these basic elements of the Python DB&amp;nbsp;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: 'Times New Roman', serif;"&gt;API's functionality already suffice for many tasks. &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: 'Times New Roman', serif;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: 'Times New Roman', serif;"&gt;&lt;b&gt;&lt;span class="Apple-style-span" style="font-size: x-large;"&gt;See Also&lt;/span&gt;&lt;/b&gt;&lt;span class="Apple-style-span" style="font-size: x-large;"&gt; : &lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="margin-bottom: 0.5cm;"&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;The Python/MySQL interface module (&lt;/span&gt;&lt;a href="http://sourceforge.net/projects/mysql-python" target="_blank"&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;http://sourceforge.net/projects/mysql-python&lt;/span&gt;&lt;/a&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;),&lt;br /&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;the Python DB API (&lt;/span&gt;&lt;a href="http://www.python.org/topics/database/DatabaseAPI-2.0.html" target="_blank"&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;http://www.python.org/topics/database/DatabaseAPI-2.0.html&lt;/span&gt;&lt;/a&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;).&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1497521753902285776-2806806819144570865?l=jagdeepmalhi.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jagdeepmalhi.blogspot.com/feeds/2806806819144570865/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://jagdeepmalhi.blogspot.com/2010/07/python-accesssing-mysql-database.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1497521753902285776/posts/default/2806806819144570865'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1497521753902285776/posts/default/2806806819144570865'/><link rel='alternate' type='text/html' href='http://jagdeepmalhi.blogspot.com/2010/07/python-accesssing-mysql-database.html' title='Python : Accesssing a MySQL Database'/><author><name>jagdeepsinghmalhi</name><uri>http://www.blogger.com/profile/08521786673136153319</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='26' src='http://1.bp.blogspot.com/_cKWqnDTAg-4/StdboO4vVMI/AAAAAAAAAAk/zqhdKK1K8vQ/S220/Photo%24072.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1497521753902285776.post-3389632471573501294</id><published>2010-07-25T14:16:00.001+05:30</published><updated>2010-08-08T17:29:54.103+05:30</updated><title type='text'>Python : Errors and Exceptions</title><content type='html'>&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;Until now error messages haven’t been more than mentioned, but if you have tried out the examples you have probably seen some. There are (at least) two distinguishable kinds of errors: &lt;/span&gt;&lt;span class="Apple-style-span" style="font-weight: normal;"&gt;&lt;em&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;syntax errors&lt;/span&gt;&lt;/em&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-weight: normal;"&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt; and &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-weight: normal;"&gt;&lt;em&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;exceptions&lt;/span&gt;&lt;/em&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-weight: normal;"&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;h2 align="LEFT"&gt;Syntax Errors&lt;/h2&gt;&lt;div align="LEFT"&gt;Syntax errors, also known as parsing errors, are perhaps the most common kind of complaint you get while you are still learning Python:&lt;/div&gt;&lt;pre class="western" style="text-align: left;"&gt;&amp;gt;&amp;gt;&amp;gt; while True print 'Hello world'&lt;br /&gt;  File "&amp;lt;stdin&amp;gt;", line 1, in ?&lt;br /&gt;    while True print 'Hello world'&lt;br /&gt;                   ^&lt;br /&gt;SyntaxError: invalid syntax&lt;/pre&gt;&lt;div align="LEFT"&gt;he parser repeats the offending line and displays a little ‘arrow’ pointing at the earliest point in the line where the error was detected. The error is caused by (or at least detected at) the token &lt;em&gt;preceding&lt;/em&gt; the arrow: in the example, the error is detected at the keyword &lt;tt class="western"&gt;&lt;a href="http://docs.python.org/reference/simple_stmts.html#print"&gt;print&lt;/a&gt;&lt;/tt&gt;, since a colon (&lt;tt class="western"&gt;':'&lt;/tt&gt;) is missing before it. File name and line number are printed so you know where to look in case the input came from a script.&lt;br /&gt;&lt;a name='more'&gt;&lt;/a&gt;&lt;/div&gt;&lt;h2 align="LEFT"&gt;Exceptions&lt;/h2&gt;&lt;div align="LEFT"&gt;Even if a statement or expression is syntactically correct, it may cause an error when an attempt is made to execute it. Errors detected during execution are called &lt;em&gt;exceptions&lt;/em&gt; and are not unconditionally fatal: you will soon learn how to handle them in Python programs. Most exceptions are not handled by programs, however, and result in error messages as shown here:&lt;/div&gt;&lt;pre class="western" style="text-align: left;"&gt;&amp;gt;&amp;gt;&amp;gt; 10 * (1/0)&lt;br /&gt;Traceback (most recent call last):&lt;br /&gt;  File "&amp;lt;stdin&amp;gt;", line 1, in ?&lt;br /&gt;ZeroDivisionError: integer division or modulo by zero&lt;br /&gt;&amp;gt;&amp;gt;&amp;gt; 4 + spam*3&lt;br /&gt;Traceback (most recent call last):&lt;br /&gt;  File "&amp;lt;stdin&amp;gt;", line 1, in ?&lt;br /&gt;NameError: name 'spam' is not defined&lt;br /&gt;&amp;gt;&amp;gt;&amp;gt; '2' + 2&lt;br /&gt;Traceback (most recent call last):&lt;br /&gt;  File "&amp;lt;stdin&amp;gt;", line 1, in ?&lt;br /&gt;TypeError: cannot concatenate 'str' and 'int' objects&lt;/pre&gt;&lt;h2 align="LEFT"&gt;Handling Exceptions&lt;/h2&gt;&lt;div align="LEFT"&gt;It is possible to write programs that handle selected exceptions. Look at the following example, which asks the user for input until a valid integer has been entered, but allows the user to interrupt the program (using &lt;tt class="western"&gt;Control-C&lt;/tt&gt; or whatever the operating system supports); note that a user-generated interruption is signalled by raising the &lt;b&gt;KeyboardInterrupt &lt;/b&gt;exception.&lt;/div&gt;&lt;pre class="western" style="text-align: left;"&gt;&amp;gt;&amp;gt;&amp;gt; while True:&lt;br /&gt;...     try:&lt;br /&gt;...         x = int(raw_input("Please enter a number: "))&lt;br /&gt;...         break&lt;br /&gt;...     except ValueError:&lt;br /&gt;...         print "Oops!  That was no valid number.  Try again..."&lt;br /&gt;...&lt;/pre&gt;The &lt;b&gt;try&lt;/b&gt; statement works as follows.&lt;br /&gt;&lt;ul&gt;&lt;li&gt;First, the try clause (the statement(s) between the try and  except keywords) is executed.   &lt;br /&gt;&lt;/li&gt;&lt;li&gt;If no exception occurs, the &lt;b&gt;except &lt;/b&gt;clause is skipped  and execution of the try statement is finished.   &lt;br /&gt;&lt;/li&gt;&lt;li&gt;If an exception occurs during execution of the try clause,  the rest of the clause is skipped. Then if its type matches the  exception named after the except keyword, the except clause is  executed, and then execution continues after the try statement.   &lt;br /&gt;&lt;/li&gt;&lt;li&gt;If an exception occurs which does not match the exception  named in the except clause, it is passed on to outer&lt;b&gt; try&lt;/b&gt;  statements; if no handler is found, it is an unhandled exception and  execution stops with a message as shown above.   &lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;h2 align="LEFT"&gt;Raising Exceptions&lt;/h2&gt;&lt;div align="LEFT"&gt;The &lt;b&gt;raise&lt;/b&gt; statement allows the programmer to force a specified exception to occur. For example:&lt;br /&gt;&lt;pre class="western"&gt;&amp;gt;&amp;gt;&amp;gt; raise NameError('HiThere')&lt;br /&gt;Traceback (most recent call last):&lt;br /&gt;  File "&amp;lt;stdin&amp;gt;", line 1, in ?&lt;br /&gt;NameError: HiThere&lt;/pre&gt;&lt;br /&gt;The sole argument to raise indicates the exception to be raised. This must be either an exception instance or an exception class (a class that derives from Exception).&lt;br /&gt;If you need to determine whether an exception was raised but don’t intend to handle it, a simpler form of the raise statement allows you to re-raise the exception:&lt;br /&gt;&lt;div align="LEFT"&gt;If you need to determine whether an exception was raised but don’t intend to handle it, a simpler form of the &lt;span style="font-style: normal;"&gt;&lt;b&gt;raise&lt;/b&gt;&lt;/span&gt; statement allows you to re-raise the exception:&lt;/div&gt;&lt;pre class="western" style="text-align: left;"&gt;&amp;gt;&amp;gt;&amp;gt; try:&lt;br /&gt;...     raise NameError('HiThere')&lt;br /&gt;... except NameError:&lt;br /&gt;...     print 'An exception flew by!'&lt;br /&gt;...     raise&lt;br /&gt;...&lt;br /&gt;An exception flew by!&lt;br /&gt;Traceback (most recent call last):&lt;br /&gt;  File "&amp;lt;stdin&amp;gt;", line 2, in ?&lt;br /&gt;NameError: HiThere&lt;/pre&gt;&lt;h2 align="LEFT"&gt;Defining Clean-up Actions&lt;/h2&gt;&lt;div align="LEFT"&gt;The &lt;tt class="western"&gt;&lt;a href="http://docs.python.org/reference/compound_stmts.html#try"&gt;try&lt;/a&gt;&lt;/tt&gt; statement has another optional clause which is intended to define clean-up actions that must be executed under all circumstances. For example:&lt;/div&gt;&lt;pre class="western"&gt;&amp;gt;&amp;gt;&amp;gt; try:&lt;br /&gt;...     raise KeyboardInterrupt&lt;br /&gt;... finally:&lt;br /&gt;...     print 'Goodbye, world!'&lt;br /&gt;...&lt;br /&gt;Goodbye, world!&lt;br /&gt;KeyboardInterrupt&lt;/pre&gt;&lt;h2 align="LEFT"&gt;Predefined Clean-up Actions&lt;/h2&gt;&lt;div align="LEFT"&gt;Some objects define standard clean-up actions to be undertaken when the object is no longer needed, regardless of whether or not the operation using the object succeeded or failed. Look at the following example, which tries to open a file and print its contents to the screen.&lt;/div&gt;&lt;pre class="western"&gt;for line in open("myfile.txt"):&lt;br /&gt;    print line&lt;/pre&gt;The problem with this code is that it leaves the file open for an indeterminate amount of time after the code has finished executing. This is not an issue in simple scripts, but can be a problem for larger applications. The &lt;tt class="western"&gt;&lt;a href="http://docs.python.org/reference/compound_stmts.html#with"&gt;with&lt;/a&gt;&lt;/tt&gt; statement allows objects like files to be used in a way that ensures they are always cleaned up promptly and correctly.&lt;br /&gt;&lt;pre class="western"&gt;with open("myfile.txt") as f:&lt;br /&gt;    for line in f:&lt;br /&gt;        print line&lt;/pre&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1497521753902285776-3389632471573501294?l=jagdeepmalhi.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jagdeepmalhi.blogspot.com/feeds/3389632471573501294/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://jagdeepmalhi.blogspot.com/2010/07/errors-and-exceptions.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1497521753902285776/posts/default/3389632471573501294'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1497521753902285776/posts/default/3389632471573501294'/><link rel='alternate' type='text/html' href='http://jagdeepmalhi.blogspot.com/2010/07/errors-and-exceptions.html' title='Python : Errors and Exceptions'/><author><name>jagdeepsinghmalhi</name><uri>http://www.blogger.com/profile/08521786673136153319</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='26' src='http://1.bp.blogspot.com/_cKWqnDTAg-4/StdboO4vVMI/AAAAAAAAAAk/zqhdKK1K8vQ/S220/Photo%24072.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1497521753902285776.post-7458556925732465593</id><published>2010-07-25T13:55:00.001+05:30</published><updated>2010-08-08T17:30:49.671+05:30</updated><title type='text'>Python : Input and Output</title><content type='html'>&lt;h2&gt;Fancier Output Formatting&lt;/h2&gt;&lt;span style="font-family: 'Times New Roman', serif;"&gt;So far we’ve encountered two ways of writing values: &lt;/span&gt;&lt;em&gt;&lt;span style="font-family: 'Times New Roman', serif;"&gt;expression statements&lt;/span&gt;&lt;/em&gt;&lt;span style="font-family: 'Times New Roman', serif;"&gt; and the &lt;/span&gt;&lt;tt class="western"&gt;&lt;a href="http://docs.python.org/reference/simple_stmts.html#print"&gt;&lt;span style="font-family: 'Times New Roman', serif;"&gt;print&lt;/span&gt;&lt;/a&gt;&lt;/tt&gt;&lt;span style="font-family: 'Times New Roman', serif;"&gt; statement. (A third way is using the &lt;/span&gt;&lt;tt class="western"&gt;&lt;span style="font-family: 'Times New Roman', serif;"&gt;write()&lt;/span&gt;&lt;/tt&gt;&lt;span style="font-family: 'Times New Roman', serif;"&gt; method of file objects; the standard output file can be referenced as &lt;/span&gt;&lt;tt class="western"&gt;&lt;span style="font-family: 'Times New Roman', serif;"&gt;sys.stdout&lt;/span&gt;&lt;/tt&gt;&lt;br /&gt;Luckily, Python has ways to convert any value to a string: pass it to the &lt;b&gt;repr() &lt;/b&gt;or &lt;b&gt;str()&lt;/b&gt; functions.&lt;br /&gt;The str() function is meant to return representations of values which are fairly human-readable, while repr() is meant to generate representations which can be read by the interpreter (or will force a SyntaxError if there is not equivalent syntax). For objects which don’t have a particular representation for human consumption, str() will return the same value as repr(). Many values, such as numbers or structures like lists and dictionaries, have the same representation using either function. Strings and floating point numbers, in particular, have two distinct representations.&lt;br /&gt;&lt;tt class="western"&gt;&lt;span style="font-family: 'Times New Roman', serif;"&gt;Some examples:&lt;/span&gt;&lt;/tt&gt;&lt;br /&gt;&lt;pre class="western"&gt;&amp;gt;&amp;gt;&amp;gt; s = 'Hello, world.'&lt;br /&gt;&amp;gt;&amp;gt;&amp;gt; str(s)&lt;br /&gt;'Hello, world.'&lt;br /&gt;&amp;gt;&amp;gt;&amp;gt; repr(s)&lt;br /&gt;"'Hello, world.'"&lt;br /&gt;&amp;gt;&amp;gt;&amp;gt; str(1.0/7.0)&lt;br /&gt;'0.142857142857'&lt;br /&gt;&amp;gt;&amp;gt;&amp;gt; repr(1.0/7.0)&lt;br /&gt;'0.14285714285714285'&lt;/pre&gt;&lt;tt class="western"&gt;&lt;span style="font-family: 'Times New Roman', serif;"&gt;&lt;/span&gt;&lt;/tt&gt;&lt;br /&gt;&lt;tt class="western"&gt;&lt;span style="font-family: 'Times New Roman', serif;"&gt;&lt;a name='more'&gt;&lt;/a&gt;&lt;br /&gt;&lt;/span&gt;&lt;/tt&gt;&lt;br /&gt;&lt;tt class="western"&gt;&lt;span style="font-family: 'Times New Roman', serif;"&gt;Basic usage of the&lt;/span&gt;&lt;/tt&gt; &lt;b&gt;str.format()&lt;/b&gt; method looks like this:&lt;br /&gt;&lt;pre class="western"&gt;&amp;gt;&amp;gt;&amp;gt; print 'We are the {} who say "{}!"'.format('knights', 'Ni')&lt;br /&gt;We are the knights who say "Ni!"&lt;/pre&gt;The brackets and characters within them (called format fields) are replaced with the objects passed into the &lt;tt class="western"&gt;&lt;a href="http://docs.python.org/library/stdtypes.html#str.format"&gt;format()&lt;/a&gt;&lt;/tt&gt; method. A number in the brackets refers to the position of the object passed into the &lt;tt class="western"&gt;&lt;a href="http://docs.python.org/library/stdtypes.html#str.format"&gt;format()&lt;/a&gt;&lt;/tt&gt; method.&lt;br /&gt;&lt;pre class="western"&gt;&amp;gt;&amp;gt;&amp;gt; print '{0} and {1}'.format('spam', 'eggs')&lt;br /&gt;spam and eggs&lt;br /&gt;&amp;gt;&amp;gt;&amp;gt; print '{1} and {0}'.format('spam', 'eggs')&lt;br /&gt;eggs and spam&lt;/pre&gt;Passing an integer after the &lt;tt class="western"&gt;':'&lt;/tt&gt; will cause that field to be a minimum number of characters wide. This is useful for making tables pretty.&lt;br /&gt;&lt;pre class="western"&gt;&amp;gt;&amp;gt;&amp;gt; table = {'Sjoerd': 4127, 'Jack': 4098, 'Dcab': 7678}&lt;br /&gt;&amp;gt;&amp;gt;&amp;gt; for name, phone in table.items():&lt;br /&gt;...     print '{0:10} ==&amp;gt; {1:10d}'.format(name, phone)&lt;br /&gt;...&lt;br /&gt;Jack       ==&amp;gt;       4098&lt;br /&gt;Dcab       ==&amp;gt;       7678&lt;br /&gt;Sjoerd     ==&amp;gt;       4127&lt;/pre&gt;If you have a really long format string that you don’t want to split up, it would be nice if you could reference the variables to be formatted by name instead of by position. This can be done by simply passing the dict and using square brackets &lt;tt class="western"&gt;'[]'&lt;/tt&gt; to access the keys&lt;br /&gt;&lt;pre class="western"&gt;&amp;gt;&amp;gt;&amp;gt; table = {'Sjoerd': 4127, 'Jack': 4098, 'Dcab': 8637678}&lt;br /&gt;&amp;gt;&amp;gt;&amp;gt; print ('Jack: {0[Jack]:d}; Sjoerd: {0[Sjoerd]:d}; '&lt;br /&gt;...        'Dcab: {0[Dcab]:d}'.format(table))&lt;br /&gt;Jack: 4098; Sjoerd: 4127; Dcab: 8637678&lt;/pre&gt;&lt;h3&gt;&lt;span class="Apple-style-span" style="font-size: x-large;"&gt; Old string formatting&lt;/span&gt;&lt;/h3&gt;The &lt;tt class="western"&gt;%&lt;/tt&gt; operator can also be used for string formatting. It interprets the left argument much like a &lt;tt class="western"&gt;&lt;b&gt;sprintf()&lt;/b&gt;&lt;/tt&gt;-style format string to be applied to the right argument, and returns the string resulting from this formatting operation. For example:&lt;br /&gt;&lt;pre class="western"&gt;&amp;gt;&amp;gt;&amp;gt; import math&lt;br /&gt;&amp;gt;&amp;gt;&amp;gt; print 'The value of PI is approximately %5.3f.' % math.pi&lt;br /&gt;The value of PI is approximately 3.142.&lt;/pre&gt;&lt;h2&gt;&lt;span class="Apple-style-span" style="font-size: x-large;"&gt; Reading and Writing Files&lt;/span&gt;&lt;/h2&gt;&lt;a href="http://www.blogger.com/post-edit.g?blogID=1497521753902285776&amp;amp;postID=7458556925732465593" name="index-1100"&gt;&lt;/a&gt;&lt;b&gt;open() &lt;/b&gt;returns a file object, and is most commonly used with two arguments: &lt;tt class="western"&gt;open(filename, mode)&lt;/tt&gt;.&lt;br /&gt;&lt;pre class="western"&gt;&amp;gt;&amp;gt;&amp;gt; f = open('/tmp/workfile', 'w')&lt;br /&gt;&amp;gt;&amp;gt;&amp;gt; print f&lt;br /&gt;&amp;lt;open file '/tmp/workfile', mode 'w' at 80a0960&amp;gt;&lt;/pre&gt;The first argument is a string containing the filename. The second argument is another string containing a few characters describing the way in which the file will be used. &lt;em&gt;mode&lt;/em&gt; can be &lt;tt class="western"&gt;'r'&lt;/tt&gt; when the file will only be read, &lt;tt class="western"&gt;'w'&lt;/tt&gt; for only writing (an existing file with the same name will be erased), and &lt;tt class="western"&gt;'a'&lt;/tt&gt; opens the file for appending; any data written to the file is automatically added to the end. &lt;tt class="western"&gt;'r+'&lt;/tt&gt; opens the file for both reading and writing. The &lt;em&gt;mode&lt;/em&gt; argument is optional; &lt;tt class="western"&gt;'r'&lt;/tt&gt; will be assumed if it’s omitted.&lt;br /&gt;&lt;h3&gt;&lt;span class="Apple-style-span" style="font-size: x-large;"&gt;Methods of File Objects&lt;/span&gt;&lt;/h3&gt;The rest of the examples in this section will assume that a file object called &lt;tt class="western"&gt;f&lt;/tt&gt; has already been created.&lt;br /&gt;To read a file’s contents, call &lt;tt class="western"&gt;&lt;b&gt;f.read(size)&lt;/b&gt;&lt;/tt&gt;, which reads some quantity of data and returns it as a string. &lt;em&gt;size&lt;/em&gt; is an optional numeric argument. When &lt;em&gt;size&lt;/em&gt; is omitted or negative, the entire contents of the file will be read and returned; it’s your problem if the file is twice as large as your machine’s memory. Otherwise, at most &lt;em&gt;size&lt;/em&gt; bytes are read and returned. If the end of the file has been reached, &lt;tt class="western"&gt;f.read()&lt;/tt&gt; will return an empty string (&lt;tt class="western"&gt;""&lt;/tt&gt;).&lt;br /&gt;&lt;pre class="western"&gt;&amp;gt;&amp;gt;&amp;gt; f.read()&lt;br /&gt;'This is the entire file.\n'&lt;br /&gt;&amp;gt;&amp;gt;&amp;gt; f.read()&lt;br /&gt;''&lt;/pre&gt;&lt;tt class="western"&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/tt&gt;&lt;br /&gt;&lt;tt class="western"&gt;&lt;b&gt;f.readline()&lt;/b&gt;&lt;/tt&gt; reads a single line from the file; a newline character (&lt;tt class="western"&gt;\n&lt;/tt&gt;) is left at the end of the string, and is only omitted on the last line of the file if the file doesn’t end in a newline. This makes the return value unambiguous; if &lt;tt class="western"&gt;f.readline()&lt;/tt&gt; returns an empty string, the end of the file has been reached, while a blank line is represented by &lt;tt class="western"&gt;'\n'&lt;/tt&gt;, a string containing only a single newline.&lt;br /&gt;&lt;pre class="western"&gt;&amp;gt;&amp;gt;&amp;gt; f.readline()&lt;br /&gt;'This is the first line of the file.\n'&lt;br /&gt;&amp;gt;&amp;gt;&amp;gt; f.readline()&lt;br /&gt;'Second line of the file\n'&lt;br /&gt;&amp;gt;&amp;gt;&amp;gt; f.readline()&lt;br /&gt;''&lt;/pre&gt;&lt;tt class="western"&gt;&lt;b&gt;f.readlines()&lt;/b&gt;&lt;/tt&gt; returns a list containing all the lines of data in the file. If given an optional parameter &lt;em&gt;sizehint&lt;/em&gt;, it reads that many bytes from the file and enough more to complete a line, and returns the lines from that. This is often used to allow efficient reading of a large file by lines, but without having to load the entire file in memory. Only complete lines will be returned.&lt;br /&gt;&lt;pre class="western"&gt;&amp;gt;&amp;gt;&amp;gt; f.readlines()&lt;br /&gt;['This is the first line of the file.\n', 'Second line of the file\n']&lt;/pre&gt;&lt;tt class="western"&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/tt&gt;&lt;br /&gt;&lt;tt class="western"&gt;&lt;b&gt;f.write(string)&lt;/b&gt;&lt;/tt&gt; writes the contents of &lt;em&gt;string&lt;/em&gt; to the file, returning &lt;tt class="western"&gt;None&lt;/tt&gt;.&lt;br /&gt;&lt;pre class="western" style="margin-bottom: 0.5cm;"&gt;&amp;gt;&amp;gt;&amp;gt; f.write('This is a test\n')&lt;/pre&gt;To write something other than a string, it needs to be converted to a string first:&lt;br /&gt;&lt;pre class="western"&gt;&amp;gt;&amp;gt;&amp;gt; value = ('the answer', 42)&lt;br /&gt;&amp;gt;&amp;gt;&amp;gt; s = str(value)&lt;br /&gt;&amp;gt;&amp;gt;&amp;gt; f.write(s)&lt;/pre&gt;&lt;tt class="western"&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/tt&gt;&lt;br /&gt;&lt;tt class="western"&gt;&lt;b&gt;f.tell()&lt;/b&gt;&lt;/tt&gt; returns an integer giving the file object’s current position in the file, measured in bytes from the beginning of the file. To change the file object’s position, use &lt;tt class="western"&gt;f.seek(offset, from_what)&lt;/tt&gt;. The position is computed from adding &lt;em&gt;offset&lt;/em&gt; to a reference point; the reference point is selected by the &lt;em&gt;from_what&lt;/em&gt; argument. A &lt;em&gt;from_what&lt;/em&gt; value of 0 measures from the beginning of the file, 1 uses the current file position, and 2 uses the end of the file as the reference point. &lt;em&gt;from_what&lt;/em&gt; can be omitted and defaults to 0, using the beginning of the file as the reference point.&lt;br /&gt;&lt;pre class="western"&gt;&amp;gt;&amp;gt;&amp;gt; f = open('/tmp/workfile', 'r+')&lt;br /&gt;&amp;gt;&amp;gt;&amp;gt; f.write('0123456789abcdef')&lt;br /&gt;&amp;gt;&amp;gt;&amp;gt; f.seek(5)     # Go to the 6th byte in the file&lt;br /&gt;&amp;gt;&amp;gt;&amp;gt; f.read(1)&lt;br /&gt;'5'&lt;br /&gt;&amp;gt;&amp;gt;&amp;gt; f.seek(-3, 2) # Go to the 3rd byte before the end&lt;br /&gt;&amp;gt;&amp;gt;&amp;gt; f.read(1)&lt;br /&gt;'d'&lt;/pre&gt;&lt;br /&gt;When you’re done with a file, call &lt;tt class="western"&gt;f.close()&lt;/tt&gt; to close it and free up any system resources taken up by the open file. After calling &lt;tt class="western"&gt;f.close()&lt;/tt&gt;, attempts to use the file object will automatically fail.&lt;br /&gt;&lt;pre class="western"&gt;&amp;gt;&amp;gt;&amp;gt; f.close()&lt;br /&gt;&amp;gt;&amp;gt;&amp;gt; f.read()&lt;br /&gt;Traceback (most recent call last):&lt;br /&gt;  File "&amp;lt;stdin&amp;gt;", line 1, in ?&lt;br /&gt;ValueError: I/O operation on closed file&lt;/pre&gt;&lt;br /&gt;It is good practice to use the  “ &lt;b&gt;with “&lt;/b&gt; keyword when dealing with file objects. This has the advantage that the file is properly closed after its suite finishes, even if an exception is raised on the way. It is also much shorter than writing equivalent try-finally blocks:&lt;br /&gt;&lt;pre class="western"&gt;&amp;gt;&amp;gt;&amp;gt; with open('/tmp/workfile', 'r') as f:&lt;br /&gt;...     read_data = f.read()&lt;br /&gt;&amp;gt;&amp;gt;&amp;gt; f.closed&lt;/pre&gt;&lt;h3&gt;The pickle Module&lt;/h3&gt;&lt;a href="http://www.blogger.com/post-edit.g?blogID=1497521753902285776&amp;amp;postID=7458556925732465593" name="index-1101"&gt;&lt;/a&gt;Strings can easily be written to and read from a file. Numbers take a bit more effort, since the &lt;tt class="western"&gt;read()&lt;/tt&gt; method only returns strings, which will have to be passed to a function like &lt;tt class="western"&gt;&lt;a href="http://docs.python.org/library/functions.html#int"&gt;&lt;span style="text-decoration: none;"&gt;&lt;b&gt;int()&lt;/b&gt;&lt;/span&gt;&lt;/a&gt;&lt;/tt&gt;&lt;span style="text-decoration: none;"&gt;&lt;b&gt;,&lt;/b&gt;&lt;/span&gt; which takes a string like &lt;tt class="western"&gt;'123'&lt;/tt&gt; and returns its numeric value 123. However, when you want to save more complex data types like lists, dictionaries, or class instances, things get a lot more complicated.&lt;br /&gt;Rather than have users be constantly writing and debugging code to save complicated data types, Python provides a standard module called &lt;tt class="western"&gt;&lt;a href="http://docs.python.org/library/pickle.html#module-pickle"&gt;&lt;span style="text-decoration: none;"&gt;&lt;b&gt;pickle&lt;/b&gt;&lt;/span&gt;&lt;/a&gt;&lt;/tt&gt;. This is an amazing module that can take almost any Python object (even some forms of Python code!), and convert it to a string representation; this process is called &lt;em&gt;pickling&lt;/em&gt;. Reconstructing the object from the string representation is called &lt;em&gt;unpickling&lt;/em&gt;. Between pickling and unpickling, the string representing the object may have been stored in a file or data, or sent over a network connection to some distant machine.&lt;br /&gt;If you have an object &lt;tt class="western"&gt;x&lt;/tt&gt;, and a file object &lt;tt class="western"&gt;f&lt;/tt&gt; that’s been opened for writing, the simplest way to pickle the object takes only one line of code:&lt;br /&gt;&lt;pre class="western" style="margin-bottom: 0.5cm;"&gt;pickle.dump(x, f)&lt;/pre&gt;To unpickle the object again, if &lt;tt class="western"&gt;f&lt;/tt&gt; is a file object which has been opened for reading:&lt;br /&gt;&lt;pre class="western" style="margin-bottom: 0.5cm;"&gt;x = pickle.load(f)&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1497521753902285776-7458556925732465593?l=jagdeepmalhi.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jagdeepmalhi.blogspot.com/feeds/7458556925732465593/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://jagdeepmalhi.blogspot.com/2010/07/python-input-and-output.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1497521753902285776/posts/default/7458556925732465593'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1497521753902285776/posts/default/7458556925732465593'/><link rel='alternate' type='text/html' href='http://jagdeepmalhi.blogspot.com/2010/07/python-input-and-output.html' title='Python : Input and Output'/><author><name>jagdeepsinghmalhi</name><uri>http://www.blogger.com/profile/08521786673136153319</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='26' src='http://1.bp.blogspot.com/_cKWqnDTAg-4/StdboO4vVMI/AAAAAAAAAAk/zqhdKK1K8vQ/S220/Photo%24072.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1497521753902285776.post-5418319034480260431</id><published>2010-07-23T23:59:00.001+05:30</published><updated>2010-08-08T17:33:57.365+05:30</updated><title type='text'>PHP String Functions</title><content type='html'>&lt;h1 class="refname"&gt;&lt;span class="Apple-style-span" style="font-size: x-large;"&gt;explode&lt;/span&gt;&lt;/h1&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;h3 class="title"&gt;Description :&lt;/h3&gt;&lt;h3 class="title"&gt;&lt;span class="Apple-style-span" style="font-size: medium; font-weight: normal;"&gt;&lt;span class="type"&gt;array&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium; font-weight: normal;"&gt;  &lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium; font-weight: normal;"&gt;&lt;span class="methodname"&gt;&lt;b&gt;explode&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium; font-weight: normal;"&gt;     ( &lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium; font-weight: normal;"&gt;&lt;span class="methodparam"&gt; &lt;span class="type"&gt;string&lt;/span&gt;  &lt;tt class="parameter"&gt;$delimiter&lt;/tt&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium; font-weight: normal;"&gt;    , &lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium; font-weight: normal;"&gt;&lt;span class="methodparam"&gt; &lt;span class="type"&gt;string&lt;/span&gt;  &lt;tt class="parameter"&gt;$string&lt;/tt&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium; font-weight: normal;"&gt;    [, &lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium; font-weight: normal;"&gt;&lt;span class="methodparam"&gt; &lt;span class="type"&gt;int&lt;/span&gt;  &lt;tt class="parameter"&gt;$limit&lt;/tt&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium; font-weight: normal;"&gt;   ] )&lt;/span&gt;&lt;/h3&gt;&lt;div class="para rdfs-comment"&gt;Returns an array of strings, each of which is a substring of    &lt;i&gt;&lt;tt class="parameter"&gt;string&lt;/tt&gt;&lt;/i&gt; formed by splitting it on    boundaries formed by the string &lt;i&gt;&lt;tt class="parameter"&gt;delimiter&lt;/tt&gt;&lt;/i&gt;. &amp;nbsp;&amp;nbsp;&lt;/div&gt;&lt;div class="para rdfs-comment"&gt;&lt;b&gt;&amp;nbsp;E&lt;/b&gt;&lt;b&gt;&lt;span class="function"&gt;&lt;b&gt;&lt;span class="Apple-style-span" style="font-weight: normal;"&gt;&lt;b&gt;xamples &amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span class="function"&gt;&lt;b&gt;explode()&lt;/b&gt;&lt;/span&gt;&amp;nbsp;&lt;/b&gt;&lt;/div&gt;&lt;div class="para rdfs-comment"&gt;&lt;/div&gt;&lt;div class="example"&gt;&lt;div class="example-contents"&gt;&lt;div class="phpcode"&gt;&lt;code&gt; &amp;lt;?php&lt;br /&gt;//&amp;nbsp;Example&amp;nbsp;1&lt;br /&gt;$pizza&amp;nbsp;&amp;nbsp;=&amp;nbsp;"piece1&amp;nbsp;piece2&amp;nbsp;piece3&amp;nbsp;piece4&amp;nbsp;piece5&amp;nbsp;piece6";&lt;br /&gt;$pieces&amp;nbsp;=&amp;nbsp;explode("&amp;nbsp;",&amp;nbsp;$pizza);&lt;br /&gt;echo&amp;nbsp;$pieces[0];&amp;nbsp;//&amp;nbsp;piece1&lt;br /&gt;echo&amp;nbsp;$pieces[1];&amp;nbsp;//&amp;nbsp;piece2&lt;br /&gt;&lt;br /&gt;//&amp;nbsp;Example&amp;nbsp;2&lt;br /&gt;$data&amp;nbsp;=&amp;nbsp;"foo:*:1023:1000::/home/foo:/bin/sh";&lt;br /&gt;list($user,&amp;nbsp;$pass,&amp;nbsp;$uid,&amp;nbsp;$gid,&amp;nbsp;$gecos,&amp;nbsp;$home,&amp;nbsp;$shell)&amp;nbsp;=&amp;nbsp;explode(":",&amp;nbsp;$data);&lt;br /&gt;echo&amp;nbsp;$user;&amp;nbsp;//&amp;nbsp;foo&lt;br /&gt;echo&amp;nbsp;$pass;&amp;nbsp;//&amp;nbsp;*&lt;br /&gt;&lt;br /&gt;?&amp;gt;  &lt;/code&gt;&lt;/div&gt;&lt;div class="phpcode"&gt;&lt;code&gt;&lt;/code&gt;&lt;br /&gt;&lt;code&gt;&lt;a name='more'&gt;&lt;/a&gt;&lt;br /&gt;&lt;/code&gt;&lt;/div&gt;&lt;div class="phpcode"&gt;&lt;code&gt;&lt;/code&gt;&lt;br /&gt;&lt;code&gt;&lt;h1 class="refname"&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;substr&lt;/span&gt;&lt;/h1&gt;&lt;div&gt;&lt;h3 class="title"&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;Description&lt;/span&gt;&lt;/h3&gt;&lt;div class="methodsynopsis dc-description"&gt;&lt;span class="type"&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;string&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;  &lt;/span&gt;&lt;span class="methodname"&gt;&lt;b&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;substr&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;     ( &lt;/span&gt;&lt;span class="methodparam"&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt; &lt;/span&gt;&lt;span class="type"&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;string&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;  &lt;/span&gt;&lt;tt class="parameter"&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;$string&lt;/span&gt;&lt;/tt&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;    , &lt;/span&gt;&lt;span class="methodparam"&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt; &lt;/span&gt;&lt;span class="type"&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;int&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;  &lt;/span&gt;&lt;tt class="parameter"&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;$start&lt;/span&gt;&lt;/tt&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;    [, &lt;/span&gt;&lt;span class="methodparam"&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt; &lt;/span&gt;&lt;span class="type"&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;int&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;  &lt;/span&gt;&lt;tt class="parameter"&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;$length&lt;/span&gt;&lt;/tt&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;   ] )&lt;/span&gt;&lt;/div&gt;&lt;div class="para rdfs-comment"&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;    Returns the portion of &lt;/span&gt;&lt;i&gt;&lt;tt class="parameter"&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;string&lt;/span&gt;&lt;/tt&gt;&lt;/i&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;  specified by the    &lt;/span&gt;&lt;i&gt;&lt;tt class="parameter"&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;start&lt;/span&gt;&lt;/tt&gt;&lt;/i&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt; and &lt;/span&gt;&lt;i&gt;&lt;tt class="parameter"&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;length&lt;/span&gt;&lt;/tt&gt;&lt;/i&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;  parameters. &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;div class="para rdfs-comment"&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;&lt;/span&gt;&lt;/div&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;&lt;div class="example"&gt;&lt;b&gt;Example Basic &lt;span class="function"&gt;&lt;b&gt;substr()&lt;/b&gt;&lt;/span&gt;  usage&lt;/b&gt;&lt;br /&gt;&lt;div class="example-contents"&gt;&lt;div class="phpcode"&gt;&lt;code&gt; &amp;lt;?php&lt;br /&gt;echo&amp;nbsp;substr('abcdef',&amp;nbsp;1);&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//&amp;nbsp;bcdef&lt;br /&gt;echo&amp;nbsp;substr('abcdef',&amp;nbsp;1,&amp;nbsp;3);&amp;nbsp;&amp;nbsp;//&amp;nbsp;bcd&lt;br /&gt;echo&amp;nbsp;substr('abcdef',&amp;nbsp;0,&amp;nbsp;4);&amp;nbsp;&amp;nbsp;//&amp;nbsp;abcd&lt;br /&gt;echo&amp;nbsp;substr('abcdef',&amp;nbsp;0,&amp;nbsp;8);&amp;nbsp;&amp;nbsp;//&amp;nbsp;abcdef&lt;br /&gt;echo&amp;nbsp;substr('abcdef',&amp;nbsp;-1,&amp;nbsp;1);&amp;nbsp;//&amp;nbsp;f&lt;br /&gt;&lt;br /&gt;//&amp;nbsp;Accessing&amp;nbsp;single&amp;nbsp;characters&amp;nbsp;in&amp;nbsp;a&amp;nbsp;string&lt;br /&gt;//&amp;nbsp;can&amp;nbsp;also&amp;nbsp;be&amp;nbsp;achieved&amp;nbsp;using&amp;nbsp;"square&amp;nbsp;brackets"&lt;br /&gt;$string&amp;nbsp;=&amp;nbsp;'abcdef';&lt;br /&gt;echo&amp;nbsp;$string[0];&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//&amp;nbsp;a&lt;br /&gt;echo&amp;nbsp;$string[3];&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//&amp;nbsp;d&lt;br /&gt;echo&amp;nbsp;$string[strlen($string)-1];&amp;nbsp;//&amp;nbsp;f&lt;br /&gt;&lt;br /&gt;?&amp;gt;  &lt;/code&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/span&gt;&lt;/div&gt;&lt;/code&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1497521753902285776-5418319034480260431?l=jagdeepmalhi.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jagdeepmalhi.blogspot.com/feeds/5418319034480260431/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://jagdeepmalhi.blogspot.com/2010/07/php-string-functions.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1497521753902285776/posts/default/5418319034480260431'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1497521753902285776/posts/default/5418319034480260431'/><link rel='alternate' type='text/html' href='http://jagdeepmalhi.blogspot.com/2010/07/php-string-functions.html' title='PHP String Functions'/><author><name>jagdeepsinghmalhi</name><uri>http://www.blogger.com/profile/08521786673136153319</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='26' src='http://1.bp.blogspot.com/_cKWqnDTAg-4/StdboO4vVMI/AAAAAAAAAAk/zqhdKK1K8vQ/S220/Photo%24072.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1497521753902285776.post-568575965905351114</id><published>2010-07-20T09:24:00.001+05:30</published><updated>2010-08-08T17:33:11.494+05:30</updated><title type='text'>Work Shop at Drishti School, Ludhiana</title><content type='html'>&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;In Drishti School, Near Ludhiana,&amp;nbsp;&lt;/span&gt;we &amp;nbsp;give a Workshop . It was  very interesting to teach little children and their teachers Linux  Softwares and to solve their problems. We are six students with Dr. H.S  Rai. Drishti School has bought 40 Linux based Tablet-PC which has  default ubuntu 8.10 installed on them. we all gave presentations on  different things.&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;div&gt;I have given my presentation on KGeography&amp;nbsp;&amp;nbsp;for kids.&lt;/div&gt;&lt;div&gt;KGeography is a Free and open source educational software game that tests students geographical knowledge&lt;/div&gt;&lt;div&gt;Besides for educational purposes, KGeography can be used for evaluating ones knowledge. Right now it has five games:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;a name='more'&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;The game tells you a map division name and you have to click on it&lt;/li&gt;&lt;li&gt;The game tells you a capital and you have to guess the division it belongs to&lt;/li&gt;&lt;li&gt;The game tells you a division and you have to guess its capital&lt;/li&gt;&lt;li&gt;The game shows you a map division flag and you have to guess its name&lt;/li&gt;&lt;li&gt;The game tells you a map division name and you have to guess its flag&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://3.bp.blogspot.com/_cKWqnDTAg-4/TF062ATfJpI/AAAAAAAAAC4/yIMzAV05Zww/s1600/Screenshot-1.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="250" src="http://3.bp.blogspot.com/_cKWqnDTAg-4/TF062ATfJpI/AAAAAAAAAC4/yIMzAV05Zww/s400/Screenshot-1.png" width="400" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;a href="http://www.slideshare.net/jagdeepsingh/kgeography"&gt;Download Presentation Here&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1497521753902285776-568575965905351114?l=jagdeepmalhi.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jagdeepmalhi.blogspot.com/feeds/568575965905351114/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://jagdeepmalhi.blogspot.com/2010/08/work-shop-at-drishti-school-ludhiana.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1497521753902285776/posts/default/568575965905351114'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1497521753902285776/posts/default/568575965905351114'/><link rel='alternate' type='text/html' href='http://jagdeepmalhi.blogspot.com/2010/08/work-shop-at-drishti-school-ludhiana.html' title='Work Shop at Drishti School, Ludhiana'/><author><name>jagdeepsinghmalhi</name><uri>http://www.blogger.com/profile/08521786673136153319</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='26' src='http://1.bp.blogspot.com/_cKWqnDTAg-4/StdboO4vVMI/AAAAAAAAAAk/zqhdKK1K8vQ/S220/Photo%24072.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_cKWqnDTAg-4/TF062ATfJpI/AAAAAAAAAC4/yIMzAV05Zww/s72-c/Screenshot-1.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1497521753902285776.post-9165119112059921926</id><published>2010-07-18T23:41:00.000+05:30</published><updated>2010-07-18T23:41:17.691+05:30</updated><title type='text'>Display an image from a MySQL database in a web page via PHP</title><content type='html'>Here's a sample HTML page we're going to include an image in:&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&amp;lt;html&amp;gt;&lt;br /&gt;&amp;lt;head&amp;gt;&lt;br /&gt;&amp;lt;title&amp;gt;Demo of Database Image in a page&amp;lt;/title&amp;gt;&lt;br /&gt;&amp;lt;/head&amp;gt;&lt;br /&gt;&amp;lt;body&amp;gt;&lt;br /&gt;Here is your picture:&amp;lt;br&amp;gt;&lt;br /&gt;&amp;lt;img src=picscript.php?imname=potwoods&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;Example by Well House Consultants&lt;br /&gt;&amp;lt;/body&amp;gt;&lt;br /&gt;&amp;lt;/html&amp;gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;Then you need the PHP script - called picscript.php in the same  directory in my example:&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&amp;lt;?php&lt;br /&gt;mysql_connect("localhost","wellho","xxxxxxx");&lt;br /&gt;mysql_select_db("wellho");&lt;br /&gt;$image = stripslashes($_REQUEST[imname]);&lt;br /&gt;$rs = mysql_query("select * from im_library where filename=\"".&lt;br /&gt;addslashes($image).".jpg\"");&lt;br /&gt;$row = mysql_fetch_assoc($rs);&lt;br /&gt;$imagebytes = $row[imgdata];&lt;br /&gt;header("Content-type: image/jpeg");&lt;br /&gt;print $imagebytes;&lt;br /&gt;?&amp;gt;&lt;/code&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1497521753902285776-9165119112059921926?l=jagdeepmalhi.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jagdeepmalhi.blogspot.com/feeds/9165119112059921926/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://jagdeepmalhi.blogspot.com/2010/07/display-image-from-mysql-database-in.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1497521753902285776/posts/default/9165119112059921926'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1497521753902285776/posts/default/9165119112059921926'/><link rel='alternate' type='text/html' href='http://jagdeepmalhi.blogspot.com/2010/07/display-image-from-mysql-database-in.html' title='Display an image from a MySQL database in a web page via PHP'/><author><name>jagdeepsinghmalhi</name><uri>http://www.blogger.com/profile/08521786673136153319</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='26' src='http://1.bp.blogspot.com/_cKWqnDTAg-4/StdboO4vVMI/AAAAAAAAAAk/zqhdKK1K8vQ/S220/Photo%24072.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1497521753902285776.post-1784365284348680330</id><published>2010-07-12T21:07:00.000+05:30</published><updated>2010-07-12T21:09:59.637+05:30</updated><title type='text'>Basic Guide lines for python coding</title><content type='html'>&lt;div style="margin-bottom: 0cm;"&gt;&lt;code class="western"&gt;&lt;span style="color: black;"&gt;&lt;span style="font-family: 'Times New Roman', serif;"&gt;&lt;span style="font-size: medium;"&gt;For Python,  has emerged as the style guide that most projects adhere to; it promotes a very readable and eye-pleasing coding style. Every Python developer should read it at some point; here are the most important points extracted for you:&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0cm;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;&lt;code class="western"&gt;&lt;span style="color: black;"&gt;&lt;span style="font-family: 'Times New Roman', serif;"&gt;&lt;span style="font-size: medium;"&gt;Use  4-space indentation, and no tabs.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;&lt;span style="font-size: medium;"&gt;4 spaces are a good compromise between small  indentation (allows greater nesting depth) and large indentation  (easier to read). Tabs introduce confusion, and are best left out.&lt;/span&gt;&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-size: medium;"&gt;Wrap lines so that they don’t exceed 79  characters.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size: medium;"&gt;This helps users with small displays and makes it  possible to have several code files side-by-side on larger displays.&lt;/span&gt;&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-size: medium;"&gt;Use blank lines to separate functions and  classes, and larger blocks of code inside functions.&lt;/span&gt;&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-size: medium;"&gt;When possible, put comments on a line of their  own.&lt;/span&gt;&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-size: medium;"&gt;Use docstrings.&lt;/span&gt;&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-size: medium;"&gt;Use spaces around operators and after commas,  but not directly inside bracketing constructs: &lt;/span&gt;&lt;tt class="western"&gt;&lt;span style="font-size: medium;"&gt;a  = f(1, 2) + g(3, 4)&lt;/span&gt;&lt;/tt&gt;&lt;span style="font-size: medium;"&gt;.&lt;/span&gt;&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-size: medium;"&gt;Name your classes and functions consistently;  the convention is to use &lt;/span&gt;&lt;tt class="western"&gt;&lt;span style="font-size: medium;"&gt;CamelCase&lt;/span&gt;&lt;/tt&gt;&lt;span style="font-size: medium;"&gt;  for classes and &lt;/span&gt;&lt;tt class="western"&gt;&lt;span style="font-size: medium;"&gt;lower_case_with_underscores&lt;/span&gt;&lt;/tt&gt;&lt;span style="font-size: medium;"&gt;  for functions and methods. Always use &lt;/span&gt;&lt;tt class="western"&gt;&lt;span style="font-size: medium;"&gt;self&lt;/span&gt;&lt;/tt&gt;&lt;span style="font-size: medium;"&gt;  as the name for the first method argument &lt;/span&gt;&lt;span style="font-size: medium;"&gt;.&lt;/span&gt;&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-size: medium;"&gt;Don’t use fancy encodings if your code is  meant to be used in international environments. Plain ASCII works  best in any case.&lt;/span&gt;&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1497521753902285776-1784365284348680330?l=jagdeepmalhi.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jagdeepmalhi.blogspot.com/feeds/1784365284348680330/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://jagdeepmalhi.blogspot.com/2010/07/basic-guide-lines-for-python-coding.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1497521753902285776/posts/default/1784365284348680330'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1497521753902285776/posts/default/1784365284348680330'/><link rel='alternate' type='text/html' href='http://jagdeepmalhi.blogspot.com/2010/07/basic-guide-lines-for-python-coding.html' title='Basic Guide lines for python coding'/><author><name>jagdeepsinghmalhi</name><uri>http://www.blogger.com/profile/08521786673136153319</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='26' src='http://1.bp.blogspot.com/_cKWqnDTAg-4/StdboO4vVMI/AAAAAAAAAAk/zqhdKK1K8vQ/S220/Photo%24072.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1497521753902285776.post-4181595411231913244</id><published>2010-07-11T23:27:00.000+05:30</published><updated>2010-07-11T23:39:15.622+05:30</updated><title type='text'>PHP function for PostGreSQL database</title><content type='html'>&lt;span style="color: black;"&gt;&lt;span style="font-family: 'Times New Roman', serif;"&gt;&lt;b&gt;pg_connect()&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color: black;"&gt;&lt;span style="font-family: 'Times New Roman', serif;"&gt; opens a connection to a PostgreSQL database specified by the &lt;/span&gt;&lt;/span&gt;&lt;tt class="western"&gt;&lt;span style="color: black;"&gt;&lt;span style="font-family: 'Times New Roman', serif;"&gt;&lt;i&gt;connection_string&lt;/i&gt;&lt;/span&gt;&lt;/span&gt;&lt;/tt&gt;&lt;span style="color: black;"&gt;&lt;span style="font-family: 'Times New Roman', serif;"&gt;. &lt;/span&gt;&lt;/span&gt; &lt;br /&gt;&lt;span style="color: black;"&gt;&lt;span style="font-family: 'Times New Roman', serif;"&gt;If a second call is made to &lt;/span&gt;&lt;/span&gt;&lt;span style="color: black;"&gt;&lt;span style="font-family: 'Times New Roman', serif;"&gt;&lt;b&gt;pg_connect()&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color: black;"&gt;&lt;span style="font-family: 'Times New Roman', serif;"&gt; with the same &lt;/span&gt;&lt;/span&gt;&lt;tt class="western"&gt;&lt;span style="color: black;"&gt;&lt;span style="font-family: 'Times New Roman', serif;"&gt;&lt;i&gt;connection_string&lt;/i&gt;&lt;/span&gt;&lt;/span&gt;&lt;/tt&gt;&lt;span style="color: black;"&gt;&lt;span style="font-family: 'Times New Roman', serif;"&gt; as an existing connection, the existing connection will be returned unless you pass &lt;/span&gt;&lt;/span&gt;&lt;tt class="western"&gt;&lt;span style="color: black;"&gt;&lt;span style="font-family: 'Times New Roman', serif;"&gt;&lt;b&gt;PGSQL_CONNECT_FORCE_NEW&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/tt&gt;&lt;span style="color: black;"&gt;&lt;span style="font-family: 'Times New Roman', serif;"&gt; as &lt;/span&gt;&lt;/span&gt;&lt;tt class="western"&gt;&lt;span style="color: black;"&gt;&lt;span style="font-family: 'Times New Roman', serif;"&gt;&lt;i&gt;connect_type&lt;/i&gt;&lt;/span&gt;&lt;/span&gt;&lt;/tt&gt;&lt;span style="color: black;"&gt;&lt;span style="font-family: 'Times New Roman', serif;"&gt;. &lt;/span&gt;&lt;/span&gt; &lt;br /&gt;&lt;span style="color: black;"&gt;&lt;span style="font-family: 'Times New Roman', serif;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: black;"&gt;&lt;span style="font-family: 'Times New Roman', serif;"&gt;The old syntax with multiple parameters &lt;/span&gt;&lt;/span&gt;&lt;strong&gt;&lt;span style="color: black;"&gt;&lt;span style="font-family: 'Times New Roman', serif;"&gt;$conn = pg_connect("host", "port", "options", "tty", "dbname") &lt;/span&gt;&lt;/span&gt;&lt;/strong&gt;&lt;span style="color: black;"&gt;&lt;span style="font-family: 'Times New Roman', serif;"&gt;has been deprecated. &lt;/span&gt;&lt;/span&gt; &lt;br /&gt;&lt;div style="margin-bottom: 0cm;"&gt;&lt;span style="color: black;"&gt;&lt;span style="font-family: 'Times New Roman', serif;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0cm;"&gt;&lt;span style="color: black;"&gt;&lt;span style="font-family: 'Times New Roman', serif;"&gt;For example :- &lt;/span&gt;&lt;/span&gt; &lt;/div&gt;&lt;div style="margin-bottom: 0cm;"&gt;&lt;span style="color: black;"&gt;&lt;span style="font-family: 'Times New Roman', serif;"&gt;$con = pg_connect("host=$dbhost user=$dbuser password=$dbpasswd dbname=$dbname" )&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0cm;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0cm;"&gt;&lt;span style="color: black;"&gt;&lt;span style="font-family: 'Times New Roman', serif;"&gt;&lt;b&gt;pg_close()&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color: black;"&gt;&lt;span style="font-family: 'Times New Roman', serif;"&gt; closes the non-persistent connection to a PostgreSQL database associated with the given &lt;/span&gt;&lt;/span&gt;&lt;tt class="western"&gt;&lt;span style="color: black;"&gt;&lt;span style="font-family: 'Times New Roman', serif;"&gt;&lt;i&gt;connection&lt;/i&gt;&lt;/span&gt;&lt;/span&gt;&lt;/tt&gt;&lt;span style="color: black;"&gt;&lt;span style="font-family: 'Times New Roman', serif;"&gt; resource. &lt;/span&gt;&lt;/span&gt; &lt;/div&gt;&lt;div style="margin-bottom: 0cm;"&gt;&lt;span style="color: black;"&gt;&lt;span style="font-family: 'Times New Roman', serif;"&gt;For example :- &lt;/span&gt;&lt;/span&gt; &lt;/div&gt;&lt;div style="margin-bottom: 0cm;"&gt;&lt;code class="western"&gt;&lt;span style="color: black;"&gt;&lt;span style="font-family: 'Times New Roman', serif;"&gt;pg_close($con);&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0cm;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0cm;"&gt;&lt;code class="western"&gt;&lt;span style="color: black;"&gt;&lt;span style="font-family: 'Times New Roman', serif;"&gt;&lt;b&gt;pg_connection_status()&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;code class="western"&gt;&lt;span style="color: black;"&gt;&lt;span style="font-family: 'Times New Roman', serif;"&gt; returns the status of the specified &lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;tt class="western"&gt;&lt;span style="color: black;"&gt;&lt;span style="font-family: 'Times New Roman', serif;"&gt;&lt;i&gt;connection&lt;/i&gt;&lt;/span&gt;&lt;/span&gt;&lt;/tt&gt;&lt;code class="western"&gt;&lt;span style="color: black;"&gt;&lt;span style="font-family: 'Times New Roman', serif;"&gt;. &lt;/span&gt;&lt;/span&gt;&lt;/code&gt; &lt;/div&gt;&lt;div style="margin-bottom: 0cm;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0cm;"&gt;&lt;code class="western"&gt;&lt;span style="color: black;"&gt;&lt;span style="font-family: 'Times New Roman', serif;"&gt;For example :-&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0cm;"&gt;&lt;code class="western"&gt;&lt;span style="color: black;"&gt;&lt;span style="font-family: 'Times New Roman', serif;"&gt;&amp;lt;?php&lt;br /&gt;&amp;nbsp;&amp;nbsp;$dbconn&amp;nbsp;=&amp;nbsp;pg_connect("dbname=publisher")&amp;nbsp;or&amp;nbsp;die("Could&amp;nbsp;not&amp;nbsp;connect");&lt;br /&gt;&amp;nbsp;&amp;nbsp;$stat&amp;nbsp;=&amp;nbsp;pg_connection_status($dbconn);&lt;br /&gt;&amp;nbsp;&amp;nbsp;if&amp;nbsp;($stat&amp;nbsp;===&amp;nbsp;PGSQL_CONNECTION_OK)&amp;nbsp;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;echo&amp;nbsp;'Connection&amp;nbsp;status&amp;nbsp;ok';&lt;br /&gt;&amp;nbsp;&amp;nbsp;}&amp;nbsp;else&amp;nbsp;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;echo&amp;nbsp;'Connection&amp;nbsp;status&amp;nbsp;bad';&lt;br /&gt;&amp;nbsp;&amp;nbsp;}&amp;nbsp;&amp;nbsp;&lt;br /&gt;?&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;/code&gt; &lt;/div&gt;&lt;div style="margin-bottom: 0cm;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0cm;"&gt;&lt;code class="western"&gt;&lt;span style="color: black;"&gt;&lt;span style="font-family: 'Times New Roman', serif;"&gt;&lt;b&gt;pg_fetch_all()&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;code class="western"&gt;&lt;span style="color: black;"&gt;&lt;span style="font-family: 'Times New Roman', serif;"&gt; returns an array that contains all rows (records) in the result resource. &lt;/span&gt;&lt;/span&gt;&lt;/code&gt; &lt;/div&gt;&lt;div style="margin-bottom: 0cm;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0cm;"&gt;&lt;code class="western"&gt;&lt;span style="color: black;"&gt;&lt;span style="font-family: 'Times New Roman', serif;"&gt;For example :-&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0cm;"&gt;&lt;code class="western"&gt;&lt;span style="color: black;"&gt;&lt;span style="font-family: 'Times New Roman', serif;"&gt;$arr&amp;nbsp;=&amp;nbsp;pg_fetch_all($result);&lt;br /&gt;&lt;br /&gt;print_r($arr); &lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0cm;"&gt;&lt;code class="western"&gt;&lt;span style="color: black;"&gt;&lt;span style="font-family: 'Times New Roman', serif;"&gt;&lt;b&gt;pg_fetch_result()&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;code class="western"&gt;&lt;span style="color: black;"&gt;&lt;span style="font-family: 'Times New Roman', serif;"&gt; returns the value of a particular row and field (column) in a PostgreSQL result resource. &lt;/span&gt;&lt;/span&gt;&lt;/code&gt; &lt;/div&gt;&lt;div style="margin-bottom: 0cm;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0cm;"&gt;&lt;code class="western"&gt;&lt;span style="color: black;"&gt;&lt;span style="font-family: 'Times New Roman', serif;"&gt;&amp;lt;?php&lt;br /&gt;$db&amp;nbsp;=&amp;nbsp;pg_connect("dbname=users&amp;nbsp;user=me")&amp;nbsp;||&amp;nbsp;die();&lt;br /&gt;&lt;br /&gt;$res&amp;nbsp;=&amp;nbsp;pg_query($db,&amp;nbsp;"SELECT&amp;nbsp;1&amp;nbsp;UNION&amp;nbsp;ALL&amp;nbsp;SELECT&amp;nbsp;2");&lt;br /&gt;&lt;br /&gt;$val&amp;nbsp;=&amp;nbsp;pg_fetch_result($res,&amp;nbsp;1,&amp;nbsp;0);&lt;br /&gt;&lt;br /&gt;echo&amp;nbsp;"First&amp;nbsp;field&amp;nbsp;in&amp;nbsp;the&amp;nbsp;second&amp;nbsp;row&amp;nbsp;is:&amp;nbsp;",&amp;nbsp;$val,&amp;nbsp;"\n";   &lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0cm;"&gt;&lt;code class="western"&gt;&lt;span style="color: black;"&gt;&lt;span style="font-family: 'Times New Roman', serif;"&gt;?&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/div&gt;&lt;code class="western"&gt;&lt;span style="color: black;"&gt;&lt;span style="font-family: 'Times New Roman', serif;"&gt;&lt;b&gt;pg_fetch_array()&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;code class="western"&gt;&lt;span style="color: black;"&gt;&lt;span style="font-family: 'Times New Roman', serif;"&gt; returns an array that corresponds to the fetched row (record). &lt;/span&gt;&lt;/span&gt;&lt;/code&gt; &lt;br /&gt;&lt;span style="color: black;"&gt;&lt;span style="font-family: 'Times New Roman', serif;"&gt;pg_fetch_array()&lt;/span&gt;&lt;/span&gt;&lt;span style="color: black;"&gt;&lt;span style="font-family: 'Times New Roman', serif;"&gt; is an extended version of &lt;a href="http://www.php.net/manual/en/function.pg-fetch-row.php"&gt;pg_fetch_row()&lt;/a&gt;. In addition to storing the data in the numeric indices (field number) to the result array, it can also store the data using associative indices (field name). It stores both indicies by default. &lt;/span&gt;&lt;/span&gt; &lt;br /&gt;&lt;div style="margin-bottom: 0cm;"&gt;&lt;code class="western"&gt;&lt;span style="color: black;"&gt;&lt;span style="font-family: 'Times New Roman', serif;"&gt;For example :-&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0cm;"&gt;&lt;code class="western"&gt;&lt;span style="color: black;"&gt;&lt;span style="font-family: 'Times New Roman', serif;"&gt;$arr&amp;nbsp;=&amp;nbsp;pg_fetch_array($result);&lt;br /&gt;echo&amp;nbsp;$arr["author"]&amp;nbsp;.&amp;nbsp;"&amp;nbsp;&amp;lt;-&amp;nbsp;Row&amp;nbsp;3&amp;nbsp;Author\n";&lt;br /&gt;echo&amp;nbsp;$arr[1]&amp;nbsp;.&amp;nbsp;"&amp;nbsp;&amp;lt;-&amp;nbsp;Row&amp;nbsp;3&amp;nbsp;E-mail\n";&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0cm;"&gt;&lt;code class="western"&gt;&lt;span style="color: black;"&gt;&lt;span style="font-family: 'Times New Roman', serif;"&gt;&lt;b&gt;pg_query()&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;code class="western"&gt;&lt;span style="color: black;"&gt;&lt;span style="font-family: 'Times New Roman', serif;"&gt; executes the &lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;tt class="western"&gt;&lt;span style="color: black;"&gt;&lt;span style="font-family: 'Times New Roman', serif;"&gt;&lt;i&gt;query&lt;/i&gt;&lt;/span&gt;&lt;/span&gt;&lt;/tt&gt;&lt;code class="western"&gt;&lt;span style="color: black;"&gt;&lt;span style="font-family: 'Times New Roman', serif;"&gt; on the specified database &lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;tt class="western"&gt;&lt;span style="color: black;"&gt;&lt;span style="font-family: 'Times New Roman', serif;"&gt;&lt;i&gt;connection&lt;/i&gt;&lt;/span&gt;&lt;/span&gt;&lt;/tt&gt;&lt;code class="western"&gt;&lt;span style="color: black;"&gt;&lt;span style="font-family: 'Times New Roman', serif;"&gt;. &lt;/span&gt;&lt;/span&gt;&lt;/code&gt; &lt;/div&gt;&lt;div style="margin-bottom: 0cm;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0cm;"&gt;&lt;code class="western"&gt;&lt;span style="color: black;"&gt;&lt;span style="font-family: 'Times New Roman', serif;"&gt;For example :-&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0cm;"&gt;&lt;code class="western"&gt;&lt;span style="color: black;"&gt;&lt;span style="font-family: 'Times New Roman', serif;"&gt;$result = pg_query($con, "SELECT * FROM $tablename where sr_no = 10");&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0cm;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0cm;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0cm;"&gt;&lt;code class="western"&gt;&lt;span style="color: black;"&gt;&lt;span style="font-family: 'Times New Roman', serif;"&gt;&lt;b&gt;pg_num_rows()&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;code class="western"&gt;&lt;span style="color: black;"&gt;&lt;span style="font-family: 'Times New Roman', serif;"&gt; will return the number of rows in a PostgreSQL result resource. &lt;/span&gt;&lt;/span&gt;&lt;/code&gt; &lt;/div&gt;&lt;div style="margin-bottom: 0cm;"&gt;&lt;code class="western"&gt;&lt;span style="color: black;"&gt;&lt;span style="font-family: 'Times New Roman', serif;"&gt;For example :-&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0.5cm;"&gt;&lt;code class="western"&gt;&lt;span style="color: black;"&gt;&lt;span style="font-family: 'Times New Roman', serif;"&gt;&amp;lt;?php&lt;br /&gt;$result&amp;nbsp;=&amp;nbsp;pg_query($conn,&amp;nbsp;"SELECT&amp;nbsp;1");&lt;br /&gt;&lt;br /&gt;$rows&amp;nbsp;=&amp;nbsp;pg_num_rows($result);&lt;br /&gt;&lt;br /&gt;echo&amp;nbsp;$rows&amp;nbsp;.&amp;nbsp;"&amp;nbsp;row(s)&amp;nbsp;returned.\n";&lt;br /&gt;?&amp;gt;   &lt;/span&gt;&lt;/span&gt;&lt;/code&gt; &lt;/div&gt;&lt;div style="margin-bottom: 0cm;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1497521753902285776-4181595411231913244?l=jagdeepmalhi.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jagdeepmalhi.blogspot.com/feeds/4181595411231913244/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://jagdeepmalhi.blogspot.com/2010/07/php-function-for-postgresql-database.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1497521753902285776/posts/default/4181595411231913244'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1497521753902285776/posts/default/4181595411231913244'/><link rel='alternate' type='text/html' href='http://jagdeepmalhi.blogspot.com/2010/07/php-function-for-postgresql-database.html' title='PHP function for PostGreSQL database'/><author><name>jagdeepsinghmalhi</name><uri>http://www.blogger.com/profile/08521786673136153319</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='26' src='http://1.bp.blogspot.com/_cKWqnDTAg-4/StdboO4vVMI/AAAAAAAAAAk/zqhdKK1K8vQ/S220/Photo%24072.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1497521753902285776.post-4695268685259842865</id><published>2010-07-08T22:03:00.000+05:30</published><updated>2010-07-08T22:07:08.504+05:30</updated><title type='text'>Basic points about Python</title><content type='html'>Python is a high-level, interpreted, interactive and object  oriented-scripting language.&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;b&gt;Python is Interpreted&lt;/b&gt;&lt;/li&gt;&lt;li&gt;&lt;b&gt;Python is Interactive&lt;/b&gt;&lt;/li&gt;&lt;li&gt;&lt;b&gt;Python is Object-Oriented&lt;/b&gt;&lt;/li&gt;&lt;li&gt;&lt;b&gt;Python is Beginner's Language&lt;/b&gt;&lt;/li&gt;&lt;/ul&gt;Python was developed by &lt;b&gt;Guido van Rossum&lt;/b&gt; in the late eighties and  early nineties at the National Research Institute for Mathematics and  Computer Science in the Netherlands.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Python's &lt;b&gt;Feature &lt;/b&gt;highlights include:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;b&gt;Easy-to-learn&lt;/b&gt;&lt;/li&gt;&lt;li&gt;&lt;b&gt;Easy-to-read&lt;/b&gt;&lt;/li&gt;&lt;li&gt;&lt;b&gt;Easy-to-maintain&lt;/b&gt;&lt;/li&gt;&lt;li&gt;&lt;b&gt;A broad standard library&lt;/b&gt;&lt;/li&gt;&lt;li&gt;&lt;b&gt;Interactive Mode&lt;/b&gt;&lt;/li&gt;&lt;li&gt;&lt;b&gt;Portable&lt;/b&gt;&lt;/li&gt;&lt;li&gt;&lt;b&gt;Extendable&lt;/b&gt;&lt;/li&gt;&lt;li&gt;&lt;b&gt;Databases&lt;/b&gt;&lt;/li&gt;&lt;li&gt;&lt;b&gt;GUI Programming&lt;/b&gt;&lt;/li&gt;&lt;li&gt;&lt;b&gt;Scalable&lt;/b&gt;&lt;br /&gt;&lt;b&gt; &lt;/b&gt; &lt;b&gt;&lt;/b&gt;&lt;b&gt;&lt;/b&gt; &lt;b&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;h1 style="display: inline !important;"&gt;&lt;span class="Apple-style-span" style="font-size: x-large;"&gt;Reserved Words:&lt;/span&gt;&lt;/h1&gt;&lt;/b&gt;&lt;br /&gt;&lt;b&gt; &lt;/b&gt; &lt;b&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;&lt;span class="Apple-style-span" style="font-weight: normal;"&gt;The following list shows the reserved words in Python. These reserved  words may not be used as constant or variable or any other identifier  names.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;&lt;span class="Apple-style-span" style="font-weight: normal;"&gt;Keywords contain lowercase letters only.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;&lt;table border="1" cellpadding="5" class="src"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td&gt;and&lt;/td&gt;&lt;td&gt;exec&lt;/td&gt;&lt;td&gt;not&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;assert&lt;/td&gt;&lt;td&gt;finally&lt;/td&gt;&lt;td&gt;or&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;break&lt;/td&gt;&lt;td&gt;for&lt;/td&gt;&lt;td&gt;pass&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;class&lt;/td&gt;&lt;td&gt;from&lt;/td&gt;&lt;td&gt;print&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;continue&lt;/td&gt;&lt;td&gt;global&lt;/td&gt;&lt;td&gt;raise&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;def&lt;/td&gt;&lt;td&gt;if&lt;/td&gt;&lt;td&gt;return&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;del&lt;/td&gt;&lt;td&gt;import&lt;/td&gt;&lt;td&gt;try&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;elif&lt;/td&gt;&lt;td&gt;in&lt;/td&gt;&lt;td&gt;while&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;else&lt;/td&gt;&lt;td&gt;is&lt;/td&gt;&lt;td&gt;with &lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;except&lt;/td&gt;&lt;td&gt;lambda&lt;/td&gt;&lt;td&gt;yield&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;h1&gt;&lt;/h1&gt;&lt;/b&gt;&lt;b&gt;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;&lt;h1 style="display: inline !important;"&gt;&lt;span class="Apple-style-span" style="font-size: x-large;"&gt;Standard Data Types:&lt;/span&gt;&lt;/h1&gt;&lt;/b&gt;&lt;b&gt;&lt;h1&gt;&lt;span class="Apple-style-span" style="font-size: medium; font-weight: normal;"&gt;&lt;b&gt; &lt;b&gt;&lt;br /&gt;&lt;h1 style="display: inline !important;"&gt;&lt;span class="Apple-style-span" style="font-size: medium; font-weight: normal;"&gt;&lt;b&gt;&lt;b&gt;&lt;br /&gt;&lt;div style="display: inline !important;"&gt;&lt;div style="display: inline !important;"&gt;&lt;span class="Apple-style-span" style="font-weight: normal;"&gt;Python has five standard data types:&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/b&gt;&lt;/b&gt;&lt;/span&gt;&lt;/h1&gt;&lt;/b&gt;&lt;/b&gt;&lt;/span&gt;&lt;b&gt;&lt;/b&gt;&lt;/h1&gt;&lt;ul&gt;&lt;li&gt;&lt;span class="Apple-style-span" style="font-weight: normal;"&gt;Numbers&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span class="Apple-style-span" style="font-weight: normal;"&gt;String&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span class="Apple-style-span" style="font-weight: normal;"&gt;List&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span class="Apple-style-span" style="font-weight: normal;"&gt;Tuple&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span class="Apple-style-span" style="font-weight: normal;"&gt;Dictionary&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/b&gt;&lt;b&gt;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;&lt;h1 style="display: inline !important;"&gt;&lt;span class="Apple-style-span" style="font-size: medium; font-weight: normal;"&gt;&lt;br /&gt;&lt;h1 style="display: inline !important;"&gt;&lt;span class="Apple-style-span" style="font-size: x-large;"&gt;The &lt;/span&gt;&lt;i&gt;&lt;span class="Apple-style-span" style="font-size: x-large;"&gt;search&lt;/span&gt;&lt;/i&gt;&lt;span class="Apple-style-span" style="font-size: x-large;"&gt; Function&lt;/span&gt;&lt;/h1&gt;&lt;/span&gt;&lt;/h1&gt;&lt;/b&gt; &lt;b&gt;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;&lt;h1&gt;&lt;span class="Apple-style-span" style="font-size: medium; font-weight: normal;"&gt;This function search for first occurrence of RE &lt;i&gt;pattern&lt;/i&gt; within  &lt;i&gt;string&lt;/i&gt; with optional &lt;i&gt;flags&lt;/i&gt;.&lt;br /&gt;Here is the syntax for this function:&lt;br /&gt;&lt;br /&gt;&lt;table cellpadding="5" cellspacing="5" class="src"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td&gt;&lt;pre&gt;re.string(pattern, string, flags=0)&lt;br /&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;Here is the description of the parameters:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;table border="1" cellpadding="5" cellspacing="0" class="src"&gt;&lt;tbody&gt;&lt;tr&gt; &lt;th width="30%"&gt;Parameter&lt;/th&gt;&lt;th&gt;Description&lt;/th&gt; &lt;/tr&gt;&lt;tr&gt;&lt;td&gt;pattern&lt;/td&gt;&lt;td&gt;This is the regular expression to be matched.&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;string&lt;/td&gt;&lt;td&gt;This is the string which would be searched to  match the pattern&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;flags&lt;/td&gt;&lt;td&gt;You can specifiy different flags using exclusive  OR (|). These are modifiers which are listed in the table below.&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;The &lt;i&gt;re.search&lt;/i&gt; function returns a &lt;b&gt;match&lt;/b&gt; object on  success, &lt;b&gt;None&lt;/b&gt; on failure. We would use &lt;i&gt;group(num)&lt;/i&gt; or &lt;i&gt;groups()&lt;/i&gt;  function of &lt;b&gt;match&lt;/b&gt; object to get matched expression.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;table border="1" cellpadding="5" cellspacing="0" class="src"&gt;&lt;tbody&gt;&lt;tr&gt; &lt;th width="30%"&gt;Match Object Methods&lt;/th&gt;&lt;th&gt;Description&lt;/th&gt; &lt;/tr&gt;&lt;tr&gt;&lt;td&gt;group(num=0)&lt;/td&gt;&lt;td&gt;This methods returns entire match (or  specific subgroup num)&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;groups()&lt;/td&gt;&lt;td&gt;This method return all matching subgroups in a  tuple (empty if there weren't any)&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;h1&gt;&lt;span class="Apple-style-span" style="font-size: x-large;"&gt;Matching vs Searching:&lt;/span&gt;&lt;/h1&gt;Python offers two different primitive operations based on regular  expressions: &lt;b&gt;match&lt;/b&gt; checks for a match only at the beginning of  the string, while &lt;b&gt;search&lt;/b&gt; checks for a match anywhere in the  string (this is what Perl does by default).&lt;span class="Apple-style-span" style="font-size: xx-large;"&gt;&lt;b&gt;&lt;span class="Apple-style-span" style="font-size: large; font-weight: normal;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;b&gt;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;&lt;h1 style="display: inline !important;"&gt;&lt;span class="Apple-style-span" style="font-size: medium; font-weight: normal;"&gt;&lt;br /&gt;&lt;h1 style="display: inline !important;"&gt;&lt;span class="Apple-style-span" style="font-size: x-large;"&gt;Search and Replace:&lt;/span&gt;&lt;/h1&gt;&lt;/span&gt;&lt;/h1&gt;&lt;/b&gt;&lt;br /&gt;Some of the most important &lt;b&gt;re&lt;/b&gt; methods that use regular  expressions is &lt;b&gt;sub&lt;/b&gt;.&lt;br /&gt;&lt;b&gt;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;&lt;h1 style="display: inline !important;"&gt;&lt;span class="Apple-style-span" style="font-size: medium; font-weight: normal;"&gt;&lt;br /&gt;&lt;h2 style="display: inline !important;"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;Syntax:&lt;/span&gt;&lt;/h2&gt;&lt;/span&gt;&lt;/h1&gt;&lt;/b&gt;&lt;table cellpadding="5" cellspacing="5" class="src"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td&gt;&lt;pre&gt;sub(pattern, repl, string, max=0)&lt;br /&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium; font-weight: normal;"&gt;This method replace all occurrences of the RE &lt;i&gt;pattern&lt;/i&gt; in &lt;i&gt;string&lt;/i&gt;  with &lt;i&gt;repl&lt;/i&gt;, substituting all occurrences unless &lt;i&gt;max&lt;/i&gt;  provided. This method would return modified string.&lt;/span&gt;&lt;/h1&gt;&lt;h1&gt;&lt;span class="Apple-style-span" style="font-size: x-large;"&gt;Built-In Class Attributes:&lt;/span&gt;&lt;/h1&gt;&lt;span class="Apple-style-span" style="font-weight: normal;"&gt;Every Python class keeps following built-in attributes and they can  be accessed using dot operator like any other attribute:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;span class="Apple-style-span" style="font-weight: normal;"&gt;__dict__ : Dictionary containing the class's namespace.&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span class="Apple-style-span" style="font-weight: normal;"&gt;__doc__ : Class documentation string, or None if  undefined. &lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span class="Apple-style-span" style="font-weight: normal;"&gt;__name__: Class name. &lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span class="Apple-style-span" style="font-weight: normal;"&gt;__module__: Module name in which the class is defined.  This attribute is "__main__" in interactive mode. &lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span class="Apple-style-span" style="font-weight: normal;"&gt;__bases__ : A possibly empty tuple containing the base  classes, in the order of their occurrence in the base class list.&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-weight: normal;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/b&gt;&lt;/li&gt;&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1497521753902285776-4695268685259842865?l=jagdeepmalhi.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jagdeepmalhi.blogspot.com/feeds/4695268685259842865/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://jagdeepmalhi.blogspot.com/2010/07/important-points-about-python.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1497521753902285776/posts/default/4695268685259842865'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1497521753902285776/posts/default/4695268685259842865'/><link rel='alternate' type='text/html' href='http://jagdeepmalhi.blogspot.com/2010/07/important-points-about-python.html' title='Basic points about Python'/><author><name>jagdeepsinghmalhi</name><uri>http://www.blogger.com/profile/08521786673136153319</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='26' src='http://1.bp.blogspot.com/_cKWqnDTAg-4/StdboO4vVMI/AAAAAAAAAAk/zqhdKK1K8vQ/S220/Photo%24072.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1497521753902285776.post-4040356738358589942</id><published>2010-07-06T22:25:00.000+05:30</published><updated>2010-07-06T22:39:30.487+05:30</updated><title type='text'>Quick  Python Tutorial</title><content type='html'>Python is an easy to learn, powerful programming language. It has  efficient high-level data structures and a simple but effective approach to object-oriented programming. Python’s elegant syntax and dynamic typing, case&amp;nbsp;sensitive&amp;nbsp;, together with its interpreted nature, make it an ideal language for  scripting and rapid application development in many areas on most platforms&lt;br /&gt;&lt;br /&gt;The Python interpreter is easily extended with new functions and data  types implemented in C or C++ (or other languages callable from C). Python is  also suitable as an extension language for customizable applications.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;&lt;span class="Apple-style-span" style="font-size: x-large;"&gt;Getting Help&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;Help in Python is always available right in the interpreter. If you  want to know how an object works, all you have to do is call  help(&amp;lt;object&amp;gt;)! Also useful are dir(), which shows you all the  object’s methods, and &amp;lt;object&amp;gt;.&lt;i&gt;doc&lt;/i&gt;, which shows you its  documentation string:&lt;br /&gt;&lt;br /&gt;&lt;span class="sy0"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt; &lt;/span&gt;&lt;span class="kw2"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;help&lt;/span&gt;&lt;/span&gt;&lt;span class="br0"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span class="nu0"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;5&lt;/span&gt;&lt;/span&gt;&lt;span class="br0"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;br /&gt;Help on &lt;/span&gt;&lt;span class="kw2"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;int&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt; &lt;/span&gt;&lt;span class="kw2"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;object&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;:&lt;/span&gt; &lt;span class="br0"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;etc etc&lt;/span&gt;&lt;span class="br0"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;br /&gt;&lt;/span&gt;  &lt;span class="sy0"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt; &lt;/span&gt;&lt;span class="kw2"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;dir&lt;/span&gt;&lt;/span&gt;&lt;span class="br0"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span class="nu0"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;5&lt;/span&gt;&lt;/span&gt;&lt;span class="br0"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;br /&gt;&lt;/span&gt; &lt;span class="br0"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;[&lt;/span&gt;&lt;/span&gt;&lt;span class="st0"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;'__abs__'&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;, &lt;/span&gt;&lt;span class="st0"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;'__add__'&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;, ...&lt;/span&gt;&lt;span class="br0"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;]&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="br0"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="br0"&gt;&lt;span class="Apple-style-span" style="font-size: x-large;"&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;&lt;b&gt;Syntax&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="br0"&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;Python has &lt;/span&gt;&lt;span style="background-color: lightgrey;"&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;no  mandatory statement termination characters&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt; and &lt;/span&gt;&lt;span style="background-color: lightgrey;"&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;blocks are specified by  indentation&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;. Indent to begin a block, dedent to end one.  Statements that expect an indentation level end in a colon (:). &lt;/span&gt;&lt;span style="background-color: lightgrey;"&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;Comments&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt; start with  the pound (#) sign and are single-line, multi-line strings are used for  &lt;/span&gt;&lt;span style="background-color: lightgrey;"&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;multi-line comments&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;.  &lt;/span&gt;&lt;span style="background-color: lightgrey;"&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;Values are assigned&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;  (in fact, objects are &lt;/span&gt;&lt;span style="background-color: lightgrey;"&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;bound&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt; to names) with the &lt;/span&gt;&lt;em&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;equals&lt;/span&gt;&lt;/em&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt; sign (”=”), and &lt;/span&gt;&lt;span style="background-color: lightgrey;"&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;equality testing&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;  is done using two &lt;/span&gt;&lt;em&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;equals&lt;/span&gt;&lt;/em&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt; signs (”&lt;/span&gt;&lt;notextile&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;==&lt;/span&gt;&lt;/notextile&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;“).  You can increment/decrement values using the += and -= operators  respectively by the right-hand amount. This works on many datatypes,  strings included. You can also use multiple variables on one line. For  example:&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="sy0"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt; myvar = &lt;/span&gt;&lt;span class="nu0"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;3&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;br /&gt;&lt;/span&gt; &lt;span class="sy0"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt; myvar += &lt;/span&gt;&lt;span class="nu0"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;2&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;br /&gt;&lt;/span&gt; &lt;span class="sy0"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt; myvar&lt;/span&gt; &lt;span class="nu0"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;5&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;br /&gt;&lt;/span&gt; &lt;span class="sy0"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt; myvar -= &lt;/span&gt;&lt;span class="nu0"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;1&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;br /&gt;&lt;/span&gt; &lt;span class="sy0"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt; myvar&lt;/span&gt; &lt;span class="nu0"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;4&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;br /&gt;&lt;/span&gt; &lt;span class="st0"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;""&lt;/span&gt;&lt;/span&gt;&lt;span class="st0"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;"This is a multiline  comment.&lt;br /&gt;The following lines concatenate the two strings."&lt;/span&gt;&lt;/span&gt;&lt;span class="st0"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;""&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;br /&gt;&lt;/span&gt; &lt;span class="sy0"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt; mystring = &lt;/span&gt;&lt;span class="st0"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;"Hello"&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;br /&gt;&lt;/span&gt; &lt;span class="sy0"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt; mystring += &lt;/span&gt;&lt;span class="st0"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;"  world."&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;br /&gt;&lt;/span&gt; &lt;span class="sy0"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt; &lt;/span&gt;&lt;span class="kw1"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;print&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;  mystring&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt; Hello world.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;b&gt;&lt;span class="Apple-style-span" style="font-size: x-large;"&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;&lt;span class="Apple-style-span" style="font-size: x-large;"&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;DataTypes&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;The data structures available in python are &lt;/span&gt;&lt;span style="background-color: lightgrey;"&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;lists, tuples and  dictionaries&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;. Sets are available in the &lt;/span&gt;&lt;code&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;sets&lt;/span&gt;&lt;/code&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt; library  (but are built-in in Python 2.5 and later). Lists are like  one-dimensional arrays (but you can also have lists of other lists),  dictionaries are associative arrays (a.k.a. hash tables) and tuples are  immutable one-dimensional arrays (Python “arrays” can be of any type, so  you can mix e.g. integers, strings, etc in lists/dictionaries/tuples).  The index of the first item in all array types is 0. Negative numbers  count from the end towards the beginning, -1 is the last item. Variables  can point to functions. The usage is as follows:&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;&lt;div class="geshifilter"&gt;&lt;div class="geshifilter-python"&gt;&lt;span class="sy0"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;  sample = &lt;/span&gt;&lt;span class="br0"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;[&lt;/span&gt;&lt;/span&gt;&lt;span class="nu0"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;1&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;, &lt;/span&gt;&lt;span class="br0"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;[&lt;/span&gt;&lt;/span&gt;&lt;span class="st0"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;"another"&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;, &lt;/span&gt;&lt;span class="st0"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;"list"&lt;/span&gt;&lt;/span&gt;&lt;span class="br0"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;]&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;, &lt;/span&gt;&lt;span class="br0"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span class="st0"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;"a"&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;, &lt;/span&gt;&lt;span class="st0"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;"tuple"&lt;/span&gt;&lt;/span&gt;&lt;span class="br0"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;span class="br0"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;]&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;br /&gt;&lt;/span&gt; &lt;span class="sy0"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt; mylist = &lt;/span&gt;&lt;span class="br0"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;[&lt;/span&gt;&lt;/span&gt;&lt;span class="st0"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;"List item 1"&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;, &lt;/span&gt;&lt;span class="nu0"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;2&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;, &lt;/span&gt;&lt;span class="nu0"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;3.14&lt;/span&gt;&lt;/span&gt;&lt;span class="br0"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;]&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;br /&gt;&lt;/span&gt; &lt;span class="sy0"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt; mylist&lt;/span&gt;&lt;span class="br0"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;[&lt;/span&gt;&lt;/span&gt;&lt;span class="nu0"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;0&lt;/span&gt;&lt;/span&gt;&lt;span class="br0"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;]&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt; = &lt;/span&gt;&lt;span class="st0"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;"List  item 1 again"&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;br /&gt;&lt;/span&gt; &lt;span class="sy0"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt; mylist&lt;/span&gt;&lt;span class="br0"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;[&lt;/span&gt;&lt;/span&gt;&lt;span class="nu0"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;-1&lt;/span&gt;&lt;/span&gt;&lt;span class="br0"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;]&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt; = &lt;/span&gt;&lt;span class="nu0"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;3.14&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;br /&gt;&lt;/span&gt; &lt;span class="sy0"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt; mydict = &lt;/span&gt;&lt;span class="br0"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;{&lt;/span&gt;&lt;/span&gt;&lt;span class="st0"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;"Key 1"&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;: &lt;/span&gt;&lt;span class="st0"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;"Value 1"&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;, &lt;/span&gt;&lt;span class="nu0"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;2&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;: &lt;/span&gt;&lt;span class="nu0"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;3&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;, &lt;/span&gt;&lt;span class="st0"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;"pi"&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;:  &lt;/span&gt;&lt;span class="nu0"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;3.14&lt;/span&gt;&lt;/span&gt;&lt;span class="br0"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;br /&gt;&lt;/span&gt; &lt;span class="sy0"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt; mydict&lt;/span&gt;&lt;span class="br0"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;[&lt;/span&gt;&lt;/span&gt;&lt;span class="st0"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;"pi"&lt;/span&gt;&lt;/span&gt;&lt;span class="br0"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;]&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt; = &lt;/span&gt;&lt;span class="nu0"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;3.15&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;br /&gt;&lt;/span&gt; &lt;span class="sy0"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt; mytuple = &lt;/span&gt;&lt;span class="br0"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span class="nu0"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;1&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;, &lt;/span&gt;&lt;span class="nu0"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;2&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;, &lt;/span&gt;&lt;span class="nu0"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;3&lt;/span&gt;&lt;/span&gt;&lt;span class="br0"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;br /&gt;&lt;/span&gt; &lt;span class="sy0"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt; myfunction = &lt;/span&gt;&lt;span class="kw2"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;len&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;br /&gt;&lt;/span&gt; &lt;span class="sy0"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt; &lt;/span&gt;&lt;span class="kw1"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;print&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;  myfunction&lt;/span&gt;&lt;span class="br0"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;mylist&lt;/span&gt;&lt;span class="br0"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;br /&gt;&lt;/span&gt; &lt;span class="nu0"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;3&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="geshifilter-python"&gt;&lt;span class="nu0"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;You can access &lt;/span&gt;&lt;span style="background-color: lightgrey;"&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;array  ranges&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt; using a colon (:). Leaving the start index empty assumes  the first item, leaving the end index assumes the last item. Negative  indexes count from the last item backwards (thus -1 is the last item)  like so:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="nu0"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;div class="geshifilter"&gt;&lt;div class="geshifilter-python" style="font-family: monospace;"&gt;&lt;span class="sy0"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt;  mylist = &lt;span class="br0"&gt;[&lt;/span&gt;&lt;span class="st0"&gt;"List item 1"&lt;/span&gt;,  &lt;span class="nu0"&gt;2&lt;/span&gt;, &lt;span class="nu0"&gt;3.14&lt;/span&gt;&lt;span class="br0"&gt;]&lt;/span&gt;&lt;br /&gt;&lt;span class="sy0"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="kw1"&gt;print&lt;/span&gt;  mylist&lt;span class="br0"&gt;[&lt;/span&gt;:&lt;span class="br0"&gt;]&lt;/span&gt;&lt;br /&gt;&lt;span class="br0"&gt;[&lt;/span&gt;&lt;span class="st0"&gt;'List item 1'&lt;/span&gt;, &lt;span class="nu0"&gt;2&lt;/span&gt;, &lt;span class="nu0"&gt;3.1400000000000001&lt;/span&gt;&lt;span class="br0"&gt;]&lt;/span&gt;&lt;br /&gt;&lt;span class="sy0"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="kw1"&gt;print&lt;/span&gt;  mylist&lt;span class="br0"&gt;[&lt;/span&gt;&lt;span class="nu0"&gt;0&lt;/span&gt;:&lt;span class="nu0"&gt;2&lt;/span&gt;&lt;span class="br0"&gt;]&lt;/span&gt;&lt;br /&gt;&lt;span class="br0"&gt;[&lt;/span&gt;&lt;span class="st0"&gt;'List item 1'&lt;/span&gt;, &lt;span class="nu0"&gt;2&lt;/span&gt;&lt;span class="br0"&gt;]&lt;/span&gt;&lt;br /&gt;&lt;span class="sy0"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="kw1"&gt;print&lt;/span&gt;  mylist&lt;span class="br0"&gt;[&lt;/span&gt;&lt;span class="nu0"&gt;-3&lt;/span&gt;:&lt;span class="nu0"&gt;-1&lt;/span&gt;&lt;span class="br0"&gt;]&lt;/span&gt;&lt;br /&gt;&lt;span class="br0"&gt;[&lt;/span&gt;&lt;span class="st0"&gt;'List item 1'&lt;/span&gt;, &lt;span class="nu0"&gt;2&lt;/span&gt;&lt;span class="br0"&gt;]&lt;/span&gt;&lt;br /&gt;&lt;span class="sy0"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="kw1"&gt;print&lt;/span&gt;  mylist&lt;span class="br0"&gt;[&lt;/span&gt;&lt;span class="nu0"&gt;1&lt;/span&gt;:&lt;span class="br0"&gt;]&lt;/span&gt;&lt;br /&gt;&lt;span class="br0"&gt;[&lt;/span&gt;&lt;span class="nu0"&gt;2&lt;/span&gt;, &lt;span class="nu0"&gt;3.14&lt;/span&gt;&lt;span class="br0"&gt;]&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="geshifilter-python"&gt;&lt;span class="nu0"&gt;&lt;b&gt;&lt;span class="Apple-style-span" style="font-size: x-large;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="geshifilter-python"&gt;&lt;span class="nu0"&gt;&lt;b&gt;&lt;span class="Apple-style-span" style="font-size: x-large;"&gt;Strings&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="geshifilter-python"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="geshifilter-python"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;Its strings can use &lt;/span&gt;&lt;span style="background-color: lightgrey;"&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;either single or double quotation marks&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;, and you can have  quotation marks of one kind inside a string that uses the other kind  (i.e. “He said ‘hello’.” is valid). Multiline strings are enclosed in &lt;/span&gt;&lt;em&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;triple  double (or single) quotes&lt;/span&gt;&lt;/em&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt; (”“”). Python &lt;/span&gt;&lt;span style="background-color: lightgrey;"&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;supports Unicode&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;  out of the box, using the syntax u“This is a unicode string”. To &lt;/span&gt;&lt;span style="background-color: lightgrey;"&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;fill a string with values&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;,  you use the % (modulo) operator and a tuple. Each %s gets replaced with  an item from the tuple, left to right, and you can also use dictionary  substitutions, like so:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;div class="geshifilter"&gt;&lt;div class="geshifilter-python"&gt;&lt;span class="sy0"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt;print  &lt;span class="st0"&gt;"Name: %s&lt;span class="es0"&gt;\n&lt;/span&gt;Number: %s&lt;span class="es0"&gt;\n&lt;/span&gt;String: %s"&lt;/span&gt; &lt;span class="sy0"&gt;%&lt;/span&gt; &lt;span class="br0"&gt;(&lt;/span&gt;myclass.&lt;span class="me1"&gt;name&lt;/span&gt;, &lt;span class="nu0"&gt;3&lt;/span&gt;, &lt;span class="nu0"&gt;3&lt;/span&gt; &lt;span class="sy0"&gt;*&lt;/span&gt;  &lt;span class="st0"&gt;"-"&lt;/span&gt;&lt;span class="br0"&gt;)&lt;/span&gt;&lt;br /&gt;Name: Poromenos&lt;br /&gt;Number: &lt;span class="nu0"&gt;3&lt;/span&gt;&lt;br /&gt;String: ---&lt;br /&gt;&lt;br /&gt;strString = &lt;span class="st0"&gt;""&lt;/span&gt;&lt;span class="st0"&gt;"This is&lt;br /&gt;a multiline&lt;br /&gt;string."&lt;/span&gt;&lt;span class="st0"&gt;""&lt;/span&gt;&lt;/div&gt;&lt;div class="geshifilter-python"&gt;&lt;span class="st0"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="geshifilter-python"&gt;&lt;span class="st0"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="st0"&gt;&lt;h2&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;&lt;span class="Apple-style-span" style="font-size: x-large;"&gt;Flow control statements&lt;/span&gt;&lt;/span&gt;&lt;/h2&gt;&lt;h2&gt;&lt;span class="Apple-style-span" style="font-size: medium; font-weight: normal;"&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;Flow control statements&amp;nbsp;are &lt;/span&gt;&lt;code&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;if&lt;/span&gt;&lt;/code&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;, &lt;/span&gt;&lt;code&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;for&lt;/span&gt;&lt;/code&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;, and &lt;/span&gt;&lt;code&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;while&lt;/span&gt;&lt;/code&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;.  There is no &lt;/span&gt;&lt;code&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;select&lt;/span&gt;&lt;/code&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;; instead, use if. Use for to enumerate  through members of a list. To obtain a list of numbers, use &lt;/span&gt;&lt;code&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;range(&amp;lt;number&amp;gt;)&lt;/span&gt;&lt;/code&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;.  These statements’ syntax is thus:&lt;/span&gt;&lt;/span&gt;&lt;/h2&gt;&lt;br /&gt;&lt;br /&gt;&lt;div class="geshifilter"&gt;&lt;div class="geshifilter-python" style="font-family: monospace;"&gt;rangelist = &lt;span class="kw2"&gt;range&lt;/span&gt;&lt;span class="br0"&gt;(&lt;/span&gt;&lt;span class="nu0"&gt;10&lt;/span&gt;&lt;span class="br0"&gt;)&lt;/span&gt;&lt;br /&gt;&lt;span class="sy0"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="kw1"&gt;print&lt;/span&gt;  rangelist&lt;br /&gt;&lt;span class="br0"&gt;[&lt;/span&gt;&lt;span class="nu0"&gt;0&lt;/span&gt;, &lt;span class="nu0"&gt;1&lt;/span&gt;,  &lt;span class="nu0"&gt;2&lt;/span&gt;, &lt;span class="nu0"&gt;3&lt;/span&gt;, &lt;span class="nu0"&gt;4&lt;/span&gt;, &lt;span class="nu0"&gt;5&lt;/span&gt;, &lt;span class="nu0"&gt;6&lt;/span&gt;,  &lt;span class="nu0"&gt;7&lt;/span&gt;, &lt;span class="nu0"&gt;8&lt;/span&gt;, &lt;span class="nu0"&gt;9&lt;/span&gt;&lt;span class="br0"&gt;]&lt;/span&gt;&lt;br /&gt;&lt;span class="kw1"&gt;for&lt;/span&gt; number &lt;span class="kw1"&gt;in&lt;/span&gt;  rangelist:&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span class="co1"&gt;# Check if number is one of&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span class="co1"&gt;# the numbers in the tuple.&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span class="kw1"&gt;if&lt;/span&gt; number &lt;span class="kw1"&gt;in&lt;/span&gt; &lt;span class="br0"&gt;(&lt;/span&gt;&lt;span class="nu0"&gt;3&lt;/span&gt;, &lt;span class="nu0"&gt;4&lt;/span&gt;,  &lt;span class="nu0"&gt;7&lt;/span&gt;, &lt;span class="nu0"&gt;9&lt;/span&gt;&lt;span class="br0"&gt;)&lt;/span&gt;:&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class="co1"&gt;# "Break" terminates a for without&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class="co1"&gt;# executing the "else" clause.&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class="kw1"&gt;break&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span class="kw1"&gt;else&lt;/span&gt;:&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class="co1"&gt;# "Continue" starts the next iteration&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class="co1"&gt;# of the loop. It's rather useless here,&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class="co1"&gt;# as it's the last statement of the loop.&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class="kw1"&gt;continue&lt;/span&gt;&lt;br /&gt;&lt;span class="kw1"&gt;else&lt;/span&gt;:&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span class="co1"&gt;# The "else" clause is optional and is&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span class="co1"&gt;# executed only if the loop didn't "break".&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span class="kw1"&gt;pass&lt;/span&gt; &lt;span class="co1"&gt;# Do nothing&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="kw1"&gt;if&lt;/span&gt; rangelist&lt;span class="br0"&gt;[&lt;/span&gt;&lt;span class="nu0"&gt;1&lt;/span&gt;&lt;span class="br0"&gt;]&lt;/span&gt; == &lt;span class="nu0"&gt;2&lt;/span&gt;:&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span class="kw1"&gt;print&lt;/span&gt; &lt;span class="st0"&gt;"The second item  (lists are 0-based) is 2"&lt;/span&gt;&lt;br /&gt;&lt;span class="kw1"&gt;elif&lt;/span&gt; rangelist&lt;span class="br0"&gt;[&lt;/span&gt;&lt;span class="nu0"&gt;1&lt;/span&gt;&lt;span class="br0"&gt;]&lt;/span&gt; == &lt;span class="nu0"&gt;3&lt;/span&gt;:&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span class="kw1"&gt;print&lt;/span&gt; &lt;span class="st0"&gt;"The second item  (lists are 0-based) is 3"&lt;/span&gt;&lt;br /&gt;&lt;span class="kw1"&gt;else&lt;/span&gt;:&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span class="kw1"&gt;print&lt;/span&gt; &lt;span class="st0"&gt;"Dunno"&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="kw1"&gt;while&lt;/span&gt; rangelist&lt;span class="br0"&gt;[&lt;/span&gt;&lt;span class="nu0"&gt;1&lt;/span&gt;&lt;span class="br0"&gt;]&lt;/span&gt; == &lt;span class="nu0"&gt;1&lt;/span&gt;:&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span class="kw1"&gt;pass&lt;/span&gt;&lt;/div&gt;&lt;div class="geshifilter-python" style="font-family: monospace;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;h2&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;&lt;span class="Apple-style-span" style="font-size: x-large;"&gt;Functions&lt;/span&gt;&lt;/span&gt;&lt;/h2&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;Functions are &lt;/span&gt;&lt;span style="background-color: lightgrey;"&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;declared  with the “def”&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt; keyword. &lt;/span&gt;&lt;span style="background-color: lightgrey;"&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;Optional arguments&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt; are set in the function  declaration after the mandatory arguments by being assigned a default  value. For &lt;/span&gt;&lt;span style="background-color: lightgrey;"&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;named  arguments&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;, the name of the argument is assigned a value.  Functions can return a tuple (and using tuple unpacking you can  effectively return &lt;/span&gt;&lt;span style="background-color: lightgrey;"&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;multiple  values&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;). &lt;/span&gt;&lt;span style="background-color: lightgrey;"&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;Lambda  functions&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt; are ad hoc functions that are comprised of a single  statement. Parameters are passed &lt;/span&gt;&lt;span style="background-color: lightgrey;"&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;by reference&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;, but immutable types (tuples, ints,  strings, etc) &lt;/span&gt;&lt;strong&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;cannot be changed&lt;/span&gt;&lt;/strong&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;. This is because &lt;/span&gt;&lt;span style="background-color: lightgrey;"&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;only the memory location  of the item is passed&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;, and &lt;/span&gt;&lt;span style="background-color: lightgrey;"&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;binding another object to a variable discards the  old one&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;, so immutable types are replaced. For example:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;div class="geshifilter"&gt;&lt;div class="geshifilter-python" style="font-family: monospace;"&gt;&lt;span class="co1"&gt;# Same as def f(x):  return x + 1&lt;/span&gt;&lt;br /&gt;functionvar = &lt;span class="kw1"&gt;lambda&lt;/span&gt; x: x + &lt;span class="nu0"&gt;1&lt;/span&gt;&lt;br /&gt;&lt;span class="sy0"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="kw1"&gt;print&lt;/span&gt;  functionvar&lt;span class="br0"&gt;(&lt;/span&gt;&lt;span class="nu0"&gt;1&lt;/span&gt;&lt;span class="br0"&gt;)&lt;/span&gt;&lt;br /&gt;&lt;span class="nu0"&gt;2&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="co1"&gt;# an_int and a_string are optional, they have default  values&lt;/span&gt;&lt;br /&gt;&lt;span class="co1"&gt;# if one is not passed (2 and "A default string",  respectively).&lt;/span&gt;&lt;br /&gt;&lt;span class="kw1"&gt;def&lt;/span&gt; passing_example&lt;span class="br0"&gt;(&lt;/span&gt;a_list,  an_int=&lt;span class="nu0"&gt;2&lt;/span&gt;, a_string=&lt;span class="st0"&gt;"A  default string"&lt;/span&gt;&lt;span class="br0"&gt;)&lt;/span&gt;:&lt;br /&gt;&amp;nbsp; &amp;nbsp; a_list.&lt;span class="me1"&gt;append&lt;/span&gt;&lt;span class="br0"&gt;(&lt;/span&gt;&lt;span class="st0"&gt;"A new item"&lt;/span&gt;&lt;span class="br0"&gt;)&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; an_int = &lt;span class="nu0"&gt;4&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span class="kw1"&gt;return&lt;/span&gt; a_list, an_int, a_string&lt;br /&gt;&lt;br /&gt;&lt;span class="sy0"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; my_list = &lt;span class="br0"&gt;[&lt;/span&gt;&lt;span class="nu0"&gt;1&lt;/span&gt;, &lt;span class="nu0"&gt;2&lt;/span&gt;, &lt;span class="nu0"&gt;3&lt;/span&gt;&lt;span class="br0"&gt;]&lt;/span&gt;&lt;br /&gt;&lt;span class="sy0"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; my_int = &lt;span class="nu0"&gt;10&lt;/span&gt;&lt;br /&gt;&lt;span class="sy0"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="kw1"&gt;print&lt;/span&gt;  passing_example&lt;span class="br0"&gt;(&lt;/span&gt;my_list, my_int&lt;span class="br0"&gt;)&lt;/span&gt;&lt;br /&gt;&lt;span class="br0"&gt;(&lt;/span&gt;&lt;span class="br0"&gt;[&lt;/span&gt;&lt;span class="nu0"&gt;1&lt;/span&gt;,  &lt;span class="nu0"&gt;2&lt;/span&gt;, &lt;span class="nu0"&gt;3&lt;/span&gt;, &lt;span class="st0"&gt;'A new item'&lt;/span&gt;&lt;span class="br0"&gt;]&lt;/span&gt;, &lt;span class="nu0"&gt;4&lt;/span&gt;, &lt;span class="st0"&gt;"A default string"&lt;/span&gt;&lt;span class="br0"&gt;)&lt;/span&gt;&lt;br /&gt;&lt;span class="sy0"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; my_list&lt;br /&gt;&lt;span class="br0"&gt;[&lt;/span&gt;&lt;span class="nu0"&gt;1&lt;/span&gt;, &lt;span class="nu0"&gt;2&lt;/span&gt;,  &lt;span class="nu0"&gt;3&lt;/span&gt;, &lt;span class="st0"&gt;'A new item'&lt;/span&gt;&lt;span class="br0"&gt;]&lt;/span&gt;&lt;br /&gt;&lt;span class="sy0"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; my_int&lt;br /&gt;&lt;span class="nu0"&gt;10&lt;/span&gt;&lt;/div&gt;&lt;div class="geshifilter-python" style="font-family: monospace;"&gt;&lt;span class="nu0"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="geshifilter-python" style="font-family: monospace;"&gt;&lt;span class="nu0"&gt;&lt;h2&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;&lt;span class="Apple-style-span" style="font-size: x-large;"&gt;Classes&lt;/span&gt;&lt;/span&gt;&lt;/h2&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;Python supports a limited form of &lt;/span&gt;&lt;span style="background-color: lightgrey;"&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;multiple inheritance&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt; in classes. &lt;/span&gt;&lt;span style="background-color: lightgrey;"&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;Private variables and  methods&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt; can be declared (by convention, this is not enforced by  the language) by adding at least two leading underscores and at most one  trailing one (e.g. “__spam”). We can also bind &lt;/span&gt;&lt;span style="background-color: lightgrey;"&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;arbitrary names&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt; to  class instances. An example follows:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;div class="geshifilter"&gt;&lt;div class="geshifilter-python" style="font-family: monospace;"&gt;&lt;span class="kw1"&gt;class&lt;/span&gt; MyClass:&lt;br /&gt;&amp;nbsp; &amp;nbsp; common = &lt;span class="nu0"&gt;10&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span class="kw1"&gt;def&lt;/span&gt; &lt;span class="kw4"&gt;__init__&lt;/span&gt;&lt;span class="br0"&gt;(&lt;/span&gt;&lt;span class="kw2"&gt;self&lt;/span&gt;&lt;span class="br0"&gt;)&lt;/span&gt;:&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class="kw2"&gt;self&lt;/span&gt;.&lt;span class="me1"&gt;myvariable&lt;/span&gt;  = &lt;span class="nu0"&gt;3&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span class="kw1"&gt;def&lt;/span&gt; myfunction&lt;span class="br0"&gt;(&lt;/span&gt;&lt;span class="kw2"&gt;self&lt;/span&gt;, arg1, arg2&lt;span class="br0"&gt;)&lt;/span&gt;:&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class="kw1"&gt;return&lt;/span&gt; &lt;span class="kw2"&gt;self&lt;/span&gt;.&lt;span class="me1"&gt;myvariable&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span class="co1"&gt;# This is the class instantiation&lt;/span&gt;&lt;br /&gt;&lt;span class="sy0"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; classinstance = MyClass&lt;span class="br0"&gt;(&lt;/span&gt;&lt;span class="br0"&gt;)&lt;/span&gt;&lt;br /&gt;&lt;span class="sy0"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; classinstance.&lt;span class="me1"&gt;myfunction&lt;/span&gt;&lt;span class="br0"&gt;(&lt;/span&gt;&lt;span class="nu0"&gt;1&lt;/span&gt;, &lt;span class="nu0"&gt;2&lt;/span&gt;&lt;span class="br0"&gt;)&lt;/span&gt;&lt;br /&gt;&lt;span class="nu0"&gt;3&lt;/span&gt;&lt;br /&gt;&lt;span class="co1"&gt;# This variable is shared by all classes.&lt;/span&gt;&lt;br /&gt;&lt;span class="sy0"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; classinstance2 = MyClass&lt;span class="br0"&gt;(&lt;/span&gt;&lt;span class="br0"&gt;)&lt;/span&gt;&lt;br /&gt;&lt;span class="sy0"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; classinstance.&lt;span class="me1"&gt;common&lt;/span&gt;&lt;br /&gt;&lt;span class="nu0"&gt;10&lt;/span&gt;&lt;br /&gt;&lt;span class="sy0"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; classinstance2.&lt;span class="me1"&gt;common&lt;/span&gt;&lt;br /&gt;&lt;span class="nu0"&gt;10&lt;/span&gt;&lt;br /&gt;&lt;span class="co1"&gt;# Note how we use the class name&lt;/span&gt;&lt;br /&gt;&lt;span class="co1"&gt;# instead of the instance.&lt;/span&gt;&lt;br /&gt;&lt;span class="sy0"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; MyClass.&lt;span class="me1"&gt;common&lt;/span&gt;  = &lt;span class="nu0"&gt;30&lt;/span&gt;&lt;br /&gt;&lt;span class="sy0"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; classinstance.&lt;span class="me1"&gt;common&lt;/span&gt;&lt;br /&gt;&lt;span class="nu0"&gt;30&lt;/span&gt;&lt;br /&gt;&lt;span class="sy0"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; classinstance2.&lt;span class="me1"&gt;common&lt;/span&gt;&lt;br /&gt;&lt;span class="nu0"&gt;30&lt;/span&gt;&lt;br /&gt;&lt;span class="co1"&gt;# This will not update the variable on the class,&lt;/span&gt;&lt;br /&gt;&lt;span class="co1"&gt;# instead it will bind a new object to the old&lt;/span&gt;&lt;br /&gt;&lt;span class="co1"&gt;# variable name.&lt;/span&gt;&lt;br /&gt;&lt;span class="sy0"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; classinstance.&lt;span class="me1"&gt;common&lt;/span&gt;  = &lt;span class="nu0"&gt;10&lt;/span&gt;&lt;br /&gt;&lt;span class="sy0"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; classinstance.&lt;span class="me1"&gt;common&lt;/span&gt;&lt;br /&gt;&lt;span class="nu0"&gt;10&lt;/span&gt;&lt;br /&gt;&lt;span class="sy0"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; classinstance2.&lt;span class="me1"&gt;common&lt;/span&gt;&lt;br /&gt;&lt;span class="nu0"&gt;30&lt;/span&gt;&lt;br /&gt;&lt;span class="sy0"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; MyClass.&lt;span class="me1"&gt;common&lt;/span&gt;  = &lt;span class="nu0"&gt;50&lt;/span&gt;&lt;br /&gt;&lt;span class="co1"&gt;# This has not changed, because "common" is&lt;/span&gt;&lt;br /&gt;&lt;span class="co1"&gt;# now an instance variable.&lt;/span&gt;&lt;br /&gt;&lt;span class="sy0"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; classinstance.&lt;span class="me1"&gt;common&lt;/span&gt;&lt;br /&gt;&lt;span class="nu0"&gt;10&lt;/span&gt;&lt;br /&gt;&lt;span class="sy0"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; classinstance2.&lt;span class="me1"&gt;common&lt;/span&gt;&lt;br /&gt;&lt;span class="nu0"&gt;50&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="co1"&gt;# This class inherits from MyClass. Multiple&lt;/span&gt;&lt;br /&gt;&lt;span class="co1"&gt;# inheritance is declared as:&lt;/span&gt;&lt;br /&gt;&lt;span class="co1"&gt;# class OtherClass(MyClass1, MyClass2, MyClassN)&lt;/span&gt;&lt;br /&gt;&lt;span class="kw1"&gt;class&lt;/span&gt; OtherClass&lt;span class="br0"&gt;(&lt;/span&gt;MyClass&lt;span class="br0"&gt;)&lt;/span&gt;:&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span class="co1"&gt;# The "self" argument is passed automatically&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span class="co1"&gt;# and refers to the class instance, so you can set&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span class="co1"&gt;# instance variables as above, but from inside the  class.&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span class="kw1"&gt;def&lt;/span&gt; &lt;span class="kw4"&gt;__init__&lt;/span&gt;&lt;span class="br0"&gt;(&lt;/span&gt;&lt;span class="kw2"&gt;self&lt;/span&gt;, arg1&lt;span class="br0"&gt;)&lt;/span&gt;:&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class="kw2"&gt;self&lt;/span&gt;.&lt;span class="me1"&gt;myvariable&lt;/span&gt;  = &lt;span class="nu0"&gt;3&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class="kw1"&gt;print&lt;/span&gt; arg1&lt;br /&gt;&lt;br /&gt;&lt;span class="sy0"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; classinstance = OtherClass&lt;span class="br0"&gt;(&lt;/span&gt;&lt;span class="st0"&gt;"hello"&lt;/span&gt;&lt;span class="br0"&gt;)&lt;/span&gt;&lt;br /&gt;hello&lt;br /&gt;&lt;span class="sy0"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; classinstance.&lt;span class="me1"&gt;myfunction&lt;/span&gt;&lt;span class="br0"&gt;(&lt;/span&gt;&lt;span class="nu0"&gt;1&lt;/span&gt;, &lt;span class="nu0"&gt;2&lt;/span&gt;&lt;span class="br0"&gt;)&lt;/span&gt;&lt;br /&gt;&lt;span class="nu0"&gt;3&lt;/span&gt;&lt;br /&gt;&lt;span class="co1"&gt;# This class doesn't have a .test member, but&lt;/span&gt;&lt;br /&gt;&lt;span class="co1"&gt;# we can add one to the instance anyway. Note&lt;/span&gt;&lt;br /&gt;&lt;span class="co1"&gt;# that this will only be a member of classinstance.&lt;/span&gt;&lt;br /&gt;&lt;span class="sy0"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; classinstance.&lt;span class="kw3"&gt;test&lt;/span&gt;  = &lt;span class="nu0"&gt;10&lt;/span&gt;&lt;br /&gt;&lt;span class="sy0"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; classinstance.&lt;span class="kw3"&gt;test&lt;/span&gt;&lt;br /&gt;&lt;span class="nu0"&gt;10&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;h2&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;&lt;span class="Apple-style-span" style="font-size: x-large;"&gt;Exceptions&lt;/span&gt;&lt;/span&gt;&lt;/h2&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;Exceptions in Python are handled with &lt;/span&gt;&lt;span style="background-color: lightgrey;"&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;try-except [exceptionname]&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt; blocks:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;div class="geshifilter"&gt;&lt;div class="geshifilter-python" style="font-family: monospace;"&gt;&lt;span class="kw1"&gt;def&lt;/span&gt;  some_function&lt;span class="br0"&gt;(&lt;/span&gt;&lt;span class="br0"&gt;)&lt;/span&gt;:&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span class="kw1"&gt;try&lt;/span&gt;:&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class="co1"&gt;# Division by zero raises an exception&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class="nu0"&gt;10&lt;/span&gt; / &lt;span class="nu0"&gt;0&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span class="kw1"&gt;except&lt;/span&gt; &lt;span class="kw2"&gt;ZeroDivisionError&lt;/span&gt;:&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class="kw1"&gt;print&lt;/span&gt; &lt;span class="st0"&gt;"Oops,  invalid."&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span class="kw1"&gt;else&lt;/span&gt;:&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class="co1"&gt;# Exception didn't occur, we're good.&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class="kw1"&gt;pass&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span class="kw1"&gt;finally&lt;/span&gt;:&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class="co1"&gt;# This is executed after the code block is run&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class="co1"&gt;# and all exceptions have been handled, even&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class="co1"&gt;# if a new exception is raised while handling.&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class="kw1"&gt;print&lt;/span&gt; &lt;span class="st0"&gt;"We're done  with that."&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="sy0"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; some_function&lt;span class="br0"&gt;(&lt;/span&gt;&lt;span class="br0"&gt;)&lt;/span&gt;&lt;br /&gt;Oops, invalid.&lt;br /&gt;&lt;span class="me1"&gt;We&lt;/span&gt;&lt;span class="st0"&gt;'re done with that.&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;h2&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;&lt;span class="Apple-style-span" style="font-size: x-large;"&gt;Importing&lt;/span&gt;&lt;/span&gt;&lt;/h2&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;External libraries are used with the &lt;/span&gt;&lt;code&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;import [libname]&lt;/span&gt;&lt;/code&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;  keyword. You can also use &lt;/span&gt;&lt;code&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;from [libname] import [funcname]&lt;/span&gt;&lt;/code&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;  for individual functions. Here is an example:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;div class="geshifilter"&gt;&lt;div class="geshifilter-python" style="font-family: monospace;"&gt;&lt;span class="kw1"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;import&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt; &lt;/span&gt;&lt;span class="kw3"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;random&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;br /&gt;&lt;/span&gt; &lt;span class="kw1"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;from&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt; &lt;/span&gt;&lt;span class="kw3"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;time&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt; &lt;/span&gt;&lt;span class="kw1"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;import&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt; clock&lt;/span&gt; &lt;br /&gt;randomint = &lt;span class="kw3"&gt;random&lt;/span&gt;.&lt;span class="me1"&gt;randint&lt;/span&gt;&lt;span class="br0"&gt;(&lt;/span&gt;&lt;span class="nu0"&gt;1&lt;/span&gt;, &lt;span class="nu0"&gt;100&lt;/span&gt;&lt;span class="br0"&gt;)&lt;/span&gt;&lt;br /&gt;&lt;span class="sy0"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="kw1"&gt;print&lt;/span&gt;  randomint&lt;br /&gt;&lt;span class="nu0"&gt;64&lt;/span&gt;&lt;/div&gt;&lt;div class="geshifilter-python"&gt;&lt;span class="nu0"&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="geshifilter-python" style="font-family: monospace;"&gt;&lt;span class="nu0"&gt;&lt;h2&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;&lt;span class="Apple-style-span" style="font-size: x-large;"&gt;File I/O&lt;/span&gt;&lt;/span&gt;&lt;/h2&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;Python has a wide array of libraries built in. As an example, here  is how &lt;/span&gt;&lt;span style="background-color: lightgrey;"&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;serializing&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;  (converting data structures to strings using the &lt;/span&gt;&lt;code&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;pickle&lt;/span&gt;&lt;/code&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;  library) with file I/O is used:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;div class="geshifilter"&gt;&lt;div class="geshifilter-python" style="font-family: monospace;"&gt;&lt;span class="kw1"&gt;import&lt;/span&gt; &lt;span class="kw3"&gt;pickle&lt;/span&gt;&lt;br /&gt;mylist = &lt;span class="br0"&gt;[&lt;/span&gt;&lt;span class="st0"&gt;"This"&lt;/span&gt;, &lt;span class="st0"&gt;"is"&lt;/span&gt;, &lt;span class="nu0"&gt;4&lt;/span&gt;, &lt;span class="nu0"&gt;13327&lt;/span&gt;&lt;span class="br0"&gt;]&lt;/span&gt;&lt;br /&gt;&lt;span class="co1"&gt;# Open the file C:\binary.dat for writing. The letter r  before the&lt;/span&gt;&lt;br /&gt;&lt;span class="co1"&gt;# filename string is used to prevent backslash  escaping.&lt;/span&gt;&lt;br /&gt;myfile = &lt;span class="kw2"&gt;file&lt;/span&gt;&lt;span class="br0"&gt;(&lt;/span&gt;r&lt;span class="st0"&gt;"C:&lt;span class="es0"&gt;\b&lt;/span&gt;inary.dat"&lt;/span&gt;, &lt;span class="st0"&gt;"w"&lt;/span&gt;&lt;span class="br0"&gt;)&lt;/span&gt;&lt;br /&gt;&lt;span class="kw3"&gt;pickle&lt;/span&gt;.&lt;span class="me1"&gt;dump&lt;/span&gt;&lt;span class="br0"&gt;(&lt;/span&gt;mylist, myfile&lt;span class="br0"&gt;)&lt;/span&gt;&lt;br /&gt;myfile.&lt;span class="me1"&gt;close&lt;/span&gt;&lt;span class="br0"&gt;(&lt;/span&gt;&lt;span class="br0"&gt;)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;myfile = &lt;span class="kw2"&gt;file&lt;/span&gt;&lt;span class="br0"&gt;(&lt;/span&gt;r&lt;span class="st0"&gt;"C:&lt;span class="es0"&gt;\t&lt;/span&gt;ext.txt"&lt;/span&gt;, &lt;span class="st0"&gt;"w"&lt;/span&gt;&lt;span class="br0"&gt;)&lt;/span&gt;&lt;br /&gt;myfile.&lt;span class="me1"&gt;write&lt;/span&gt;&lt;span class="br0"&gt;(&lt;/span&gt;&lt;span class="st0"&gt;"This is a sample string"&lt;/span&gt;&lt;span class="br0"&gt;)&lt;/span&gt;&lt;br /&gt;myfile.&lt;span class="me1"&gt;close&lt;/span&gt;&lt;span class="br0"&gt;(&lt;/span&gt;&lt;span class="br0"&gt;)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;myfile = &lt;span class="kw2"&gt;file&lt;/span&gt;&lt;span class="br0"&gt;(&lt;/span&gt;r&lt;span class="st0"&gt;"C:&lt;span class="es0"&gt;\t&lt;/span&gt;ext.txt"&lt;/span&gt;&lt;span class="br0"&gt;)&lt;/span&gt;&lt;br /&gt;&lt;span class="sy0"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="kw1"&gt;print&lt;/span&gt;  myfile.&lt;span class="me1"&gt;read&lt;/span&gt;&lt;span class="br0"&gt;(&lt;/span&gt;&lt;span class="br0"&gt;)&lt;/span&gt;&lt;br /&gt;&lt;span class="st0"&gt;'This is a sample string'&lt;/span&gt;&lt;br /&gt;myfile.&lt;span class="me1"&gt;close&lt;/span&gt;&lt;span class="br0"&gt;(&lt;/span&gt;&lt;span class="br0"&gt;)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="co1"&gt;# Open the file for reading.&lt;/span&gt;&lt;br /&gt;myfile = &lt;span class="kw2"&gt;file&lt;/span&gt;&lt;span class="br0"&gt;(&lt;/span&gt;r&lt;span class="st0"&gt;"C:&lt;span class="es0"&gt;\b&lt;/span&gt;inary.dat"&lt;/span&gt;&lt;span class="br0"&gt;)&lt;/span&gt;&lt;br /&gt;loadedlist = &lt;span class="kw3"&gt;pickle&lt;/span&gt;.&lt;span class="me1"&gt;load&lt;/span&gt;&lt;span class="br0"&gt;(&lt;/span&gt;myfile&lt;span class="br0"&gt;)&lt;/span&gt;&lt;br /&gt;myfile.&lt;span class="me1"&gt;close&lt;/span&gt;&lt;span class="br0"&gt;(&lt;/span&gt;&lt;span class="br0"&gt;)&lt;/span&gt;&lt;br /&gt;&lt;span class="sy0"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="kw1"&gt;print&lt;/span&gt;  loadedlist&lt;br /&gt;&lt;span class="br0"&gt;[&lt;/span&gt;&lt;span class="st0"&gt;'This'&lt;/span&gt;, &lt;span class="st0"&gt;'is'&lt;/span&gt;, &lt;span class="nu0"&gt;4&lt;/span&gt;, &lt;span class="nu0"&gt;13327&lt;/span&gt;&lt;span class="br0"&gt;]&lt;/span&gt;&lt;/div&gt;&lt;div class="geshifilter-python" style="font-family: monospace;"&gt;&lt;span class="br0"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="geshifilter-python" style="font-family: monospace;"&gt;&lt;span class="br0"&gt;&lt;h2&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;Miscellaneous&lt;/span&gt;&lt;/span&gt;&lt;/h2&gt;&lt;ul&gt;&lt;li&gt;&lt;span style="background-color: lightgrey;"&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;Conditions can  be chained&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;. &lt;/span&gt;&lt;code&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;1 &amp;lt; a &amp;lt; 3&lt;/span&gt;&lt;/code&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt; checks that a is both  less than 3 and more than 1.&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;You can use &lt;/span&gt;&lt;code&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;del&lt;/span&gt;&lt;/code&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt; to &lt;/span&gt;&lt;span style="background-color: lightgrey;"&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;delete variables or items in arrays&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;.&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;&lt;span style="background-color: lightgrey;"&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;List  comprehensions&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt; provide a powerful way to create and manipulate  lists. They consist of an expression followed by a &lt;/span&gt;&lt;code&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;for&lt;/span&gt;&lt;/code&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;  clause followed by zero or more &lt;/span&gt;&lt;code&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;if&lt;/span&gt;&lt;/code&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt; or &lt;/span&gt;&lt;code&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;for&lt;/span&gt;&lt;/code&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;  clauses, like so:&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;div class="geshifilter"&gt;&lt;div class="geshifilter-python" style="font-family: monospace;"&gt;&lt;span class="sy0"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt;  lst1 = &lt;span class="br0"&gt;[&lt;/span&gt;&lt;span class="nu0"&gt;1&lt;/span&gt;, &lt;span class="nu0"&gt;2&lt;/span&gt;, &lt;span class="nu0"&gt;3&lt;/span&gt;&lt;span class="br0"&gt;]&lt;/span&gt;&lt;br /&gt;&lt;span class="sy0"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; lst2 = &lt;span class="br0"&gt;[&lt;/span&gt;&lt;span class="nu0"&gt;3&lt;/span&gt;, &lt;span class="nu0"&gt;4&lt;/span&gt;, &lt;span class="nu0"&gt;5&lt;/span&gt;&lt;span class="br0"&gt;]&lt;/span&gt;&lt;br /&gt;&lt;span class="sy0"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="kw1"&gt;print&lt;/span&gt; &lt;span class="br0"&gt;[&lt;/span&gt;x &lt;span class="sy0"&gt;*&lt;/span&gt; y &lt;span class="kw1"&gt;for&lt;/span&gt;  x &lt;span class="kw1"&gt;in&lt;/span&gt; lst1 &lt;span class="kw1"&gt;for&lt;/span&gt; y &lt;span class="kw1"&gt;in&lt;/span&gt; lst2&lt;span class="br0"&gt;]&lt;/span&gt;&lt;br /&gt;&lt;span class="br0"&gt;[&lt;/span&gt;&lt;span class="nu0"&gt;3&lt;/span&gt;, &lt;span class="nu0"&gt;4&lt;/span&gt;,  &lt;span class="nu0"&gt;5&lt;/span&gt;, &lt;span class="nu0"&gt;6&lt;/span&gt;, &lt;span class="nu0"&gt;8&lt;/span&gt;, &lt;span class="nu0"&gt;10&lt;/span&gt;, &lt;span class="nu0"&gt;9&lt;/span&gt;,  &lt;span class="nu0"&gt;12&lt;/span&gt;, &lt;span class="nu0"&gt;15&lt;/span&gt;&lt;span class="br0"&gt;]&lt;/span&gt;&lt;br /&gt;&lt;span class="sy0"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="kw1"&gt;print&lt;/span&gt; &lt;span class="br0"&gt;[&lt;/span&gt;x &lt;span class="kw1"&gt;for&lt;/span&gt; x &lt;span class="kw1"&gt;in&lt;/span&gt;  lst1 &lt;span class="kw1"&gt;if&lt;/span&gt; &lt;span class="nu0"&gt;4&lt;/span&gt; &lt;span class="sy0"&gt;&amp;gt;&lt;/span&gt; x &lt;span class="sy0"&gt;&amp;gt;&lt;/span&gt; &lt;span class="nu0"&gt;1&lt;/span&gt;&lt;span class="br0"&gt;]&lt;/span&gt;&lt;br /&gt;&lt;span class="br0"&gt;[&lt;/span&gt;&lt;span class="nu0"&gt;2&lt;/span&gt;, &lt;span class="nu0"&gt;3&lt;/span&gt;&lt;span class="br0"&gt;]&lt;/span&gt;&lt;br /&gt;&lt;span class="co1"&gt;# Check if an item has a specific property.&lt;/span&gt;&lt;br /&gt;&lt;span class="co1"&gt;# "any" returns true if any item in the list is true.&lt;/span&gt;&lt;br /&gt;&lt;span class="sy0"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; any&lt;span class="br0"&gt;(&lt;/span&gt;&lt;span class="br0"&gt;[&lt;/span&gt;i &lt;span class="sy0"&gt;%&lt;/span&gt; &lt;span class="nu0"&gt;3&lt;/span&gt;  &lt;span class="kw1"&gt;for&lt;/span&gt; i &lt;span class="kw1"&gt;in&lt;/span&gt; &lt;span class="br0"&gt;[&lt;/span&gt;&lt;span class="nu0"&gt;3&lt;/span&gt;, &lt;span class="nu0"&gt;3&lt;/span&gt;,  &lt;span class="nu0"&gt;4&lt;/span&gt;, &lt;span class="nu0"&gt;4&lt;/span&gt;, &lt;span class="nu0"&gt;3&lt;/span&gt;&lt;span class="br0"&gt;]&lt;/span&gt;&lt;span class="br0"&gt;]&lt;/span&gt;&lt;span class="br0"&gt;)&lt;/span&gt;&lt;br /&gt;&lt;span class="kw2"&gt;True&lt;/span&gt;&lt;br /&gt;&lt;span class="co1"&gt;# This is because 4 % 3 = 1, and 1 is true, so any()&lt;/span&gt;&lt;br /&gt;&lt;span class="co1"&gt;# returns True.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="co1"&gt;# Check how many items have this property.&lt;/span&gt;&lt;br /&gt;&lt;span class="sy0"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="kw2"&gt;sum&lt;/span&gt;&lt;span class="br0"&gt;(&lt;/span&gt;&lt;span class="nu0"&gt;1&lt;/span&gt; &lt;span class="kw1"&gt;for&lt;/span&gt;  i &lt;span class="kw1"&gt;in&lt;/span&gt; &lt;span class="br0"&gt;[&lt;/span&gt;&lt;span class="nu0"&gt;3&lt;/span&gt;, &lt;span class="nu0"&gt;3&lt;/span&gt;, &lt;span class="nu0"&gt;4&lt;/span&gt;,  &lt;span class="nu0"&gt;4&lt;/span&gt;, &lt;span class="nu0"&gt;3&lt;/span&gt;&lt;span class="br0"&gt;]&lt;/span&gt;  &lt;span class="kw1"&gt;if&lt;/span&gt; i == &lt;span class="nu0"&gt;4&lt;/span&gt;&lt;span class="br0"&gt;)&lt;/span&gt;&lt;br /&gt;&lt;span class="nu0"&gt;2&lt;/span&gt;&lt;br /&gt;&lt;span class="sy0"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="kw1"&gt;del&lt;/span&gt; lst1&lt;span class="br0"&gt;[&lt;/span&gt;&lt;span class="nu0"&gt;0&lt;/span&gt;&lt;span class="br0"&gt;]&lt;/span&gt;&lt;br /&gt;&lt;span class="sy0"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="kw1"&gt;print&lt;/span&gt;  lst1&lt;br /&gt;&lt;span class="br0"&gt;[&lt;/span&gt;&lt;span class="nu0"&gt;2&lt;/span&gt;, &lt;span class="nu0"&gt;3&lt;/span&gt;&lt;span class="br0"&gt;]&lt;/span&gt;&lt;br /&gt;&lt;span class="sy0"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="kw1"&gt;del&lt;/span&gt; lst1&lt;/div&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;&lt;span style="background-color: lightgrey;"&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;Global  variables&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt; are declared outside of functions and can be read  without any special declarations, but if you want to write to them you  must declare them at the beginning of the function with the “global”  keyword, otherwise Python will bind that object to a new local variable  (be careful of that, it’s a small catch that can get you if you don’t  know it). For example:&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;div class="geshifilter"&gt;&lt;div class="geshifilter-python" style="font-family: monospace;"&gt;number = &lt;span class="nu0"&gt;5&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="kw1"&gt;def&lt;/span&gt; myfunc&lt;span class="br0"&gt;(&lt;/span&gt;&lt;span class="br0"&gt;)&lt;/span&gt;:&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span class="co1"&gt;# This will print 5.&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span class="kw1"&gt;print&lt;/span&gt; number&lt;br /&gt;&lt;br /&gt;&lt;span class="kw1"&gt;def&lt;/span&gt; anotherfunc&lt;span class="br0"&gt;(&lt;/span&gt;&lt;span class="br0"&gt;)&lt;/span&gt;:&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span class="co1"&gt;# This raises an exception because the variable  has not&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span class="co1"&gt;# been bound before printing. Python knows that it  an&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span class="co1"&gt;# object will be bound to it later and creates a  new, local&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span class="co1"&gt;# object instead of accessing the global one.&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span class="kw1"&gt;print&lt;/span&gt; number&lt;br /&gt;&amp;nbsp; &amp;nbsp; number = &lt;span class="nu0"&gt;3&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="kw1"&gt;def&lt;/span&gt; yetanotherfunc&lt;span class="br0"&gt;(&lt;/span&gt;&lt;span class="br0"&gt;)&lt;/span&gt;:&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span class="kw1"&gt;global&lt;/span&gt; number&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span class="co1"&gt;# This will correctly change the global.&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; number = &lt;span class="nu0"&gt;3&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;h2&gt;&lt;/h2&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1497521753902285776-4040356738358589942?l=jagdeepmalhi.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jagdeepmalhi.blogspot.com/feeds/4040356738358589942/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://jagdeepmalhi.blogspot.com/2010/07/quick-python-tutorial.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1497521753902285776/posts/default/4040356738358589942'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1497521753902285776/posts/default/4040356738358589942'/><link rel='alternate' type='text/html' href='http://jagdeepmalhi.blogspot.com/2010/07/quick-python-tutorial.html' title='Quick  Python Tutorial'/><author><name>jagdeepsinghmalhi</name><uri>http://www.blogger.com/profile/08521786673136153319</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='26' src='http://1.bp.blogspot.com/_cKWqnDTAg-4/StdboO4vVMI/AAAAAAAAAAk/zqhdKK1K8vQ/S220/Photo%24072.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1497521753902285776.post-8869671064090915624</id><published>2010-07-04T22:45:00.000+05:30</published><updated>2010-07-04T22:52:56.910+05:30</updated><title type='text'>PostgreSQL</title><content type='html'>&lt;h2 id="Introduction"&gt;Introduction&lt;/h2&gt;&lt;span class="anchor" id="line-4"&gt;&lt;/span&gt;&lt;span class="anchor" id="line-5"&gt;&lt;/span&gt;&lt;br /&gt;&lt;div class="line862"&gt;PostgreSQL is a powerful object-relational database  management system, provided under a flexible BSD-style license.&lt;sup&gt;[1]&lt;/sup&gt;  PostgreSQL contains many advanced features, is very fast and standards  compliant. &lt;span class="anchor" id="line-6"&gt;&lt;/span&gt;&lt;span class="anchor" id="line-7"&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="line862"&gt;PostgreSQL has bindings for  many programming languages such as C, C++, &lt;a class="http" href="http://python.org/"&gt;Python&lt;/a&gt;, Java, PHP, Ruby... It can be used  to power anything from simple web applications to massive databases with  millions of records.&lt;/div&gt;&lt;h2 id="Installation"&gt;Installation in&amp;nbsp;Ubuntu&amp;nbsp;Server&lt;/h2&gt;&lt;div&gt;&lt;div class="line862"&gt;To install &lt;strong&gt;Postgresql &lt;/strong&gt;&amp;nbsp;you may  use the command line and type: &lt;span class="anchor" id="line-38"&gt;&lt;/span&gt;&lt;span class="anchor" id="line-39"&gt;&lt;/span&gt;&lt;span class="anchor" id="line-40"&gt;&lt;/span&gt;&lt;/div&gt;&lt;pre&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre&gt;$sudo apt-get install postgresql&lt;/pre&gt;&lt;/div&gt;&lt;h3 id="Administration"&gt;Administration&lt;/h3&gt;&lt;span class="anchor" id="line-44"&gt;&lt;/span&gt;&lt;span class="anchor" id="line-45"&gt;&lt;/span&gt;&lt;br /&gt;&lt;div class="line874"&gt;pgAdmin III is a handy GUI for  PostgreSQL, it is essential to beginners. To install it, type at the  command line: &lt;span class="anchor" id="line-46"&gt;&lt;/span&gt;&lt;span class="anchor" id="line-47"&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="line867"&gt;&lt;span class="anchor" id="line-48"&gt;&lt;/span&gt;&lt;span class="anchor" id="line-49"&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="line862"&gt;&lt;span class="Apple-style-span" style="font-family: monospace; white-space: pre;"&gt; sudo apt-get install pgadmin3&lt;/span&gt;&lt;/div&gt;&lt;h2 id="Basic Server Setup"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;Basic Server Setup&lt;/span&gt;&lt;/h2&gt;&lt;span class="anchor" id="line-54"&gt;&lt;/span&gt;&lt;span class="anchor" id="line-55"&gt;&lt;/span&gt;&lt;br /&gt;&lt;div class="line862"&gt;To start off, we need to change  the PostgreSQL postgres user password; we will not be able to access the  server otherwise. As the “postgres” Linux user, we will execute the  psql command.&lt;/div&gt;&lt;div class="line862"&gt;&lt;/div&gt;&lt;h3 id="Create database"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/h3&gt;&lt;h3 id="Create database"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;Create&amp;nbsp;New User&lt;/span&gt;&lt;/h3&gt;&lt;div class="line862"&gt;In a terminal, type:&amp;nbsp;&lt;/div&gt;&lt;div class="line862"&gt;&lt;/div&gt;&lt;div class="line862"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;@-desktop:~$ sudo -s&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="line862"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;root@-desktop:~# su - postgres&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="line862"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;postgres@-desktop:~$ createuser jagdeep&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="line862"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Shall the new role be a superuser? (y/n) y&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="line862"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Shall the new role be allowed to create databases? (y/n) y&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="line862"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Shall the new role be allowed to create more new roles? (y/n) y&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="line862"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;postgres@-desktop:~$ exit&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="line862"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;logout&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="line862"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;root@-desktop:~# exit&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="line862"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;exit&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;pre&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;@-desktop:~$ sudo -u postgres psql postgres&lt;br /&gt;psql (8.4.4)&lt;br /&gt;Type "help" for help.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;div class="line874"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="line874"&gt;Set a password for the "postgres" database role using  the command: &lt;span class="anchor" id="line-72"&gt;&lt;/span&gt;&lt;span class="anchor" id="line-73"&gt;&lt;/span&gt;&lt;span class="anchor" id="line-74"&gt;&lt;/span&gt;&lt;/div&gt;&lt;pre&gt;\password postgres&lt;/pre&gt;&lt;div class="line874"&gt;and give your  password when prompted. The password text will be hidden from the  console for security purposes. &lt;span class="anchor" id="line-76"&gt;&lt;/span&gt;&lt;span class="anchor" id="line-77"&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="line862"&gt;Type  Control+D to exit the posgreSQL prompt.&amp;nbsp;&lt;/div&gt;&lt;div class="line862"&gt;&lt;/div&gt;&lt;h3 id="Create database"&gt;&lt;br /&gt;&lt;/h3&gt;&lt;h3 id="Create database"&gt;Create database&lt;/h3&gt;&lt;span class="anchor" id="line-81"&gt;&lt;/span&gt;&lt;span class="anchor" id="line-82"&gt;&lt;/span&gt;&lt;br /&gt;&lt;div class="line874"&gt;To create the first database,  which we will call "mydb", simply type : &lt;span class="anchor" id="line-83"&gt;&lt;/span&gt;&lt;span class="anchor" id="line-84"&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="line867"&gt;&lt;span class="anchor" id="line-85"&gt;&lt;/span&gt;&lt;span class="anchor" id="line-86"&gt;&lt;/span&gt;&lt;/div&gt;&lt;pre&gt;sudo -u postgres createdb mydb&lt;/pre&gt;&lt;div class="line862"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="line862"&gt;&lt;b&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;Install phppgadmin for GUI&amp;nbsp;Inter-phase&amp;nbsp;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div class="line862"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;sudo apt-get install phppgadmin&lt;/span&gt;&lt;/div&gt;&lt;div class="line862"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="line862"&gt;&lt;b&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;&lt;span class="Apple-style-span" style="font-size: x-large;"&gt;How to login using phppgadmin&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div class="line862"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="line862"&gt;First of all enable login of postgres user via phppgadmin by editing&lt;br /&gt;the /etc/phppgadmin/config.inc.php or {your phppgadmin install&lt;br /&gt;path}/conf/config.inc.php file change the following line-:&lt;br /&gt;&lt;br /&gt;$conf['extra_login_security'] = true;&lt;br /&gt;to:&lt;br /&gt;$conf['extra_login_security'] = false;&lt;br /&gt;&lt;br /&gt;Now you will be able to login in phppdadmin using postgres username.&lt;/div&gt;&lt;div class="line862"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="line862"&gt;After login using postgres or any other superuser account. Create a&lt;br /&gt;new role (by clicking on Roles and then Create role).Give desired&lt;br /&gt;username, password and tick on following checkboxes-:&lt;br /&gt;&lt;br /&gt;Inherits privileges?&lt;br /&gt;Can login?&lt;br /&gt;&lt;br /&gt;Then press create button to create new user.&lt;br /&gt;&lt;br /&gt;Now give the select privilege on the tables to the newly created&lt;br /&gt;user.This can be done by clicking on the table name and grant&lt;br /&gt;permissions under privileges tab.Give select privileges to newly&lt;br /&gt;created user.Now that user can browse through the table and see&lt;br /&gt;individual values.&lt;br /&gt;Logout from superuser account and login again using newly created user&lt;br /&gt;to verify the results.&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1497521753902285776-8869671064090915624?l=jagdeepmalhi.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jagdeepmalhi.blogspot.com/feeds/8869671064090915624/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://jagdeepmalhi.blogspot.com/2010/07/postgresql.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1497521753902285776/posts/default/8869671064090915624'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1497521753902285776/posts/default/8869671064090915624'/><link rel='alternate' type='text/html' href='http://jagdeepmalhi.blogspot.com/2010/07/postgresql.html' title='PostgreSQL'/><author><name>jagdeepsinghmalhi</name><uri>http://www.blogger.com/profile/08521786673136153319</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='26' src='http://1.bp.blogspot.com/_cKWqnDTAg-4/StdboO4vVMI/AAAAAAAAAAk/zqhdKK1K8vQ/S220/Photo%24072.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1497521753902285776.post-2063288247260099481</id><published>2010-07-03T16:54:00.000+05:30</published><updated>2010-07-04T22:55:42.981+05:30</updated><title type='text'>Design your URLs in Django</title><content type='html'>&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;&lt;span class="Apple-style-span" style="white-space: pre;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Times New Roman';"&gt;&lt;span class="Apple-style-span" style="white-space: normal;"&gt;  &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Times New Roman';"&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Times New Roman';"&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Times New Roman';"&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Times New Roman';"&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Times New Roman';"&gt;&lt;div style="line-height: 0.48cm; margin-bottom: 0.5cm; orphans: 2; widows: 2;"&gt;&lt;span class="Apple-style-span" style="color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif;"&gt;The first step of writing views is to design your URL structure. You do this by creating a Python module, called a URLconf. URLconfs are how Django associates a given URL with given Python code.&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #333333;"&gt;&lt;span style="font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif;"&gt;&lt;span style="font-style: normal;"&gt;&lt;span style="font-weight: normal;"&gt; When a user requests a Django-powered page, the system looks at the&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;tt class="western"&gt;&lt;a href="http://docs.djangoproject.com/en/1.2/ref/settings/#setting-ROOT_URLCONF"&gt;&lt;span style="color: #d52a33;"&gt;&lt;span style="text-decoration: none;"&gt;&lt;span style="font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif;"&gt;&lt;span style="font-style: normal;"&gt;&lt;span style="font-weight: normal;"&gt;ROOT_URLCONF&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;&lt;/tt&gt;&lt;span style="color: #333333;"&gt;&lt;span style="font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif;"&gt;&lt;span style="font-style: normal;"&gt;&lt;span style="font-weight: normal;"&gt;&amp;nbsp;setting, which contains a string in Python dotted syntax. Django loads that module and looks for a module-level variable called&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;tt class="western"&gt;&lt;span style="color: #333333;"&gt;&lt;span style="font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif;"&gt;&lt;span style="font-style: normal;"&gt;&lt;span style="font-weight: normal;"&gt;urlpatterns&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/tt&gt;&lt;span style="color: #333333;"&gt;&lt;span style="font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif;"&gt;&lt;span style="font-style: normal;"&gt;&lt;span style="font-weight: normal;"&gt;, which is a sequence of tuples in the following format:&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color: #333333;"&gt;&lt;span style="font-family: monospace;"&gt;&lt;span style="font-style: normal;"&gt;&lt;span style="font-weight: normal;"&gt;(regular expression, Python callback function [, optional dictionary])&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;pre class="western" style="line-height: 0.48cm; orphans: 2; widows: 2;"&gt;&lt;span style="color: #333333;"&gt;&lt;span style="font-family: Times, 'Times New Roman', serif;"&gt;&lt;span style="font-style: normal;"&gt;&lt;span style="font-weight: normal;"&gt;When you ran &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;tt class="western"&gt;&lt;span style="color: #333333;"&gt;&lt;span style="font-family: Times, 'Times New Roman', serif;"&gt;&lt;span style="font-style: normal;"&gt;&lt;span style="font-weight: normal;"&gt;django-admin.py startproject&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/tt&gt;&lt;tt class="western"&gt;&lt;span style="color: #333333;"&gt;&lt;span style="font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif;"&gt;&lt;span style="font-style: normal;"&gt;&lt;span style="font-weight: normal;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/tt&gt;&lt;tt class="western"&gt;&lt;span style="color: #333333;"&gt;&lt;span style="font-family: Times, 'Times New Roman', serif;"&gt;&lt;span style="font-style: normal;"&gt;&lt;span style="font-weight: normal;"&gt;mysite &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/tt&gt;&lt;span style="color: #333333;"&gt;&lt;span style="font-family: Times, 'Times New Roman', serif;"&gt;&lt;span style="font-style: normal;"&gt;&lt;span style="font-weight: normal;"&gt;at the beginning of&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #333333;"&gt;&lt;span style="font-family: Times, 'Times New Roman', serif;"&gt;&lt;span style="font-style: normal;"&gt;&lt;span style="font-weight: normal;"&gt;it created a default URLconf in &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;tt class="western"&gt;&lt;span style="color: #333333;"&gt;&lt;span style="font-family: Times, 'Times New Roman', serif;"&gt;&lt;span style="font-style: normal;"&gt;&lt;span style="font-weight: normal;"&gt;mysite/urls.py&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/tt&gt;&lt;span style="color: #333333;"&gt;&lt;span style="font-family: Times, 'Times New Roman', serif;"&gt;&lt;span style="font-style: normal;"&gt;&lt;span style="font-weight: normal;"&gt;. It alsoautomatically set your &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;tt class="western"&gt;&lt;a href="http://docs.djangoproject.com/en/1.2/ref/settings/#setting-ROOT_URLCONF"&gt;&lt;span style="color: #d52a33;"&gt;&lt;span style="text-decoration: none;"&gt;&lt;span style="font-family: Times, 'Times New Roman', serif;"&gt;&lt;span style="font-style: normal;"&gt;&lt;span style="font-weight: normal;"&gt;ROOT_URLCONF&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;&lt;/tt&gt;&lt;br /&gt;&lt;span style="color: #333333;"&gt;&lt;span style="font-family: Times, 'Times New Roman', serif;"&gt;&lt;span style="font-style: normal;"&gt;&lt;span style="font-weight: normal;"&gt;setting (in &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;tt class="western"&gt;&lt;span style="color: #333333;"&gt;&lt;span style="font-family: Times, 'Times New Roman', serif;"&gt;&lt;span style="font-style: normal;"&gt;&lt;span style="font-weight: normal;"&gt;settings.py&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/tt&gt;&lt;span style="color: #333333;"&gt;&lt;span style="font-family: Times, 'Times New Roman', serif;"&gt;&lt;span style="font-style: normal;"&gt;&lt;span style="font-weight: normal;"&gt;) to point at that file:&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: #333333;"&gt;&lt;span style="font-style: normal;"&gt;&lt;span style="font-weight: normal;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;ROOT_URLCONF = 'mysite.urls'&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #333333;"&gt;&lt;span style="font-family: Times, 'Times New Roman', serif;"&gt;&lt;span style="font-style: normal;"&gt;&lt;span style="font-weight: normal;"&gt;Time for an example. Edit &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;tt class="western"&gt;&lt;span style="color: #333333;"&gt;&lt;span style="font-family: Times, 'Times New Roman', serif;"&gt;&lt;span style="font-style: normal;"&gt;&lt;span style="font-weight: normal;"&gt;mysite/urls.py&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/tt&gt;&lt;span style="color: #333333;"&gt;&lt;span style="font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif;"&gt;&lt;span style="font-style: normal;"&gt;&lt;span style="font-weight: normal;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color: #333333;"&gt;&lt;span style="font-family: Times, 'Times New Roman', serif;"&gt;&lt;span style="font-style: normal;"&gt;&lt;span style="font-weight: normal;"&gt;so it looks like this:&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color: #333333;"&gt;&lt;span style="font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif;"&gt;&lt;span style="font-style: normal;"&gt;&lt;span style="font-weight: normal;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #333333;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;from django.conf.urls.defaults import *&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: #333333;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;from django.contrib import admin&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: #333333;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;admin.autodiscover()&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: #333333;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;urlpatterns = patterns('',&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: #333333;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;    &lt;/span&gt;&lt;span style="font-style: normal;"&gt;&lt;span style="font-weight: normal;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;(r'^polls/$', 'mysite.polls.views.index'),&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: #333333;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;    &lt;/span&gt;&lt;span style="font-style: normal;"&gt;&lt;span style="font-weight: normal;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;(r'^polls/(?P&amp;lt;poll_id&amp;gt;\d+)/$', 'mysite.polls.views.detail'),&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: #333333;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;    &lt;/span&gt;&lt;span style="font-style: normal;"&gt;&lt;span style="font-weight: normal;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;(r'^polls/(?P&amp;lt;poll_id&amp;gt;\d+)/results/$', 'mysite.polls.views.results'),&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: #333333;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;    &lt;/span&gt;&lt;span style="font-style: normal;"&gt;&lt;span style="font-weight: normal;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;(r'^polls/(?P&amp;lt;poll_id&amp;gt;\d+)/vote/$', 'mysite.polls.views.vote'),&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: #333333;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;    &lt;/span&gt;&lt;span style="font-style: normal;"&gt;&lt;span style="font-weight: normal;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;(r'^admin/', include(admin.site.urls)),&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: #333333;"&gt;&lt;span style="font-size: x-small;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="western" style="line-height: 0.48cm; orphans: 2; widows: 2;"&gt;&lt;span style="color: #333333;"&gt;&lt;span style="font-family: Times, 'Times New Roman', serif;"&gt;&lt;span style="font-size: x-large;"&gt;&lt;b&gt;Write your first view&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="western" style="line-height: 0.48cm; orphans: 2; widows: 2;"&gt;&lt;span style="color: #333333;"&gt;&lt;span style="font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif;"&gt;&lt;span style="font-family: Times, 'Times New Roman', serif;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="western" style="line-height: 0.48cm; orphans: 2; widows: 2;"&gt;&lt;span style="color: #333333;"&gt;&lt;span style="font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif;"&gt;&lt;span style="font-family: Times, 'Times New Roman', serif;"&gt;Well, we haven't created any views yet -- we just have the URLconf. But let's make sure Django is following the&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="western" style="line-height: 0.48cm; orphans: 2; widows: 2;"&gt;&lt;span style="color: #333333;"&gt;&lt;span style="font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif;"&gt;&lt;span style="font-family: Times, 'Times New Roman', serif;"&gt;URLconf properly.&lt;/span&gt;&lt;span style="font-family: Times, 'Times New Roman', serif;"&gt;Fire up the Django development Web server:&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #333333;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;python manage.py runserver&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #333333;"&gt;&lt;span style="font-family: Times, 'Times New Roman', serif;"&gt;&lt;span style="font-style: normal;"&gt;&lt;span style="font-weight: normal;"&gt;Now go to "&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;a href="http://localhost:8000/polls/"&gt;&lt;span style="color: #d52a33;"&gt;&lt;span style="text-decoration: none;"&gt;&lt;span style="font-family: Times, 'Times New Roman', serif;"&gt;&lt;span style="font-style: normal;"&gt;&lt;span style="font-weight: normal;"&gt;http://localhost:8000/polls/&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;&lt;span style="color: #333333;"&gt;&lt;span style="font-family: Times, 'Times New Roman', serif;"&gt;&lt;span style="font-style: normal;"&gt;&lt;span style="font-weight: normal;"&gt;" on your domain in your Web browser. You should get a pleasantly-colored error&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="western" style="line-height: 0.48cm; orphans: 2; widows: 2;"&gt;&lt;span style="color: #333333;"&gt;&lt;span style="font-family: Times, 'Times New Roman', serif;"&gt;&lt;span style="font-style: normal;"&gt;&lt;span style="font-weight: normal;"&gt;page with the following message:&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #333333;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;ViewDoesNotExist at /polls/&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: #333333;"&gt;&lt;span style="font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif;"&gt;Tried index in module mysite.polls.views. Error was: 'module'&lt;span class="Apple-style-span" style="color: black; font-family: monospace;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color: #333333;"&gt;&lt;span style="font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif;"&gt;object has no attribute 'index'&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="western" style="line-height: 0.48cm; orphans: 2; widows: 2;"&gt;&lt;span style="color: #333333;"&gt;&lt;span style="font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color: #333333;"&gt;&lt;span style="font-family: Times, 'Times New Roman', serif;"&gt;&lt;span style="font-style: normal;"&gt;&lt;span style="font-weight: normal;"&gt;This error happened because you haven't written a function &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;tt class="western"&gt;&lt;span style="color: #333333;"&gt;&lt;span style="font-family: Times, 'Times New Roman', serif;"&gt;&lt;span style="font-style: normal;"&gt;&lt;span style="font-weight: normal;"&gt;index()&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/tt&gt;&lt;span style="color: #333333;"&gt;&lt;span style="font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif;"&gt;&lt;span style="font-style: normal;"&gt;&lt;span style="font-weight: normal;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color: #333333;"&gt;&lt;span style="font-family: Times, 'Times New Roman', serif;"&gt;&lt;span style="font-style: normal;"&gt;&lt;span style="font-weight: normal;"&gt;in the module &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;tt class="western"&gt;&lt;span style="color: #333333;"&gt;&lt;span style="font-family: Times, 'Times New Roman', serif;"&gt;&lt;span style="font-style: normal;"&gt;&lt;span style="font-weight: normal;"&gt;mysite/polls/views.py&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/tt&gt;&lt;span style="color: #333333;"&gt;&lt;span style="font-family: Times, 'Times New Roman', serif;"&gt;&lt;span style="font-style: normal;"&gt;&lt;span style="font-weight: normal;"&gt;.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre class="western" style="line-height: 0.48cm; orphans: 2; widows: 2;"&gt;&lt;span style="color: #333333;"&gt;&lt;span style="font-family: Times, 'Times New Roman', serif;"&gt;&lt;span style="font-style: normal;"&gt;&lt;span style="font-weight: normal;"&gt;Write the first view. Open the file &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;tt class="western"&gt;&lt;span style="color: #333333;"&gt;&lt;span style="font-family: Times, 'Times New Roman', serif;"&gt;&lt;span style="font-style: normal;"&gt;&lt;span style="font-weight: normal;"&gt;mysite/polls/views.py &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/tt&gt;&lt;span style="color: #333333;"&gt;&lt;span style="font-family: Times, 'Times New Roman', serif;"&gt;&lt;span style="font-style: normal;"&gt;&lt;span style="font-weight: normal;"&gt;and put the following Python code in it:&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="western" style="line-height: 0.48cm; orphans: 2; widows: 2;"&gt;&lt;span style="color: #333333;"&gt;&lt;span style="font-style: normal;"&gt;&lt;span style="font-weight: normal;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;from django.http import HttpResponse&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: #333333;"&gt;&lt;span style="font-style: normal;"&gt;&lt;span style="font-weight: normal;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;def index(request):&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: #333333;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;    &lt;/span&gt;&lt;span style="font-style: normal;"&gt;&lt;span style="font-weight: normal;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;return HttpResponse("Hello, world. You're at the poll index.")&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: #333333;"&gt;&lt;span style="font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif;"&gt;&lt;span style="font-family: Times, 'Times New Roman', serif;"&gt;This is the simplest view possible. Go to "/polls/" in your browser, and you should see your text. Now lets add a few more&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="western" style="line-height: 0.48cm; orphans: 2; widows: 2;"&gt;&lt;span style="color: #333333;"&gt;&lt;span style="font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif;"&gt;&lt;span style="font-family: Times, 'Times New Roman', serif;"&gt; views. These views are slightly different, because they take an argument (which, remember, is passed in from whatever&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="western" style="line-height: 0.48cm; orphans: 2; widows: 2;"&gt;&lt;span style="color: #333333;"&gt;&lt;span style="font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif;"&gt;&lt;span style="font-family: Times, 'Times New Roman', serif;"&gt;was captured by the regular expression in the URLconf): &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #333333;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;def detail(request, poll_id):&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: #333333;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;    &lt;/span&gt;&lt;span style="font-style: normal;"&gt;&lt;span style="font-weight: normal;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;return HttpResponse("You're looking at poll %s." % poll_id)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: #333333;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;def results(request, poll_id):&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: #333333;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;    &lt;/span&gt;&lt;span style="font-style: normal;"&gt;&lt;span style="font-weight: normal;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;return HttpResponse("You're looking at the results of poll %s." % poll_id)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: #333333;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;def vote(request, poll_id):&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: #333333;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;    &lt;/span&gt;&lt;span style="font-style: normal;"&gt;&lt;span style="font-weight: normal;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;return HttpResponse("You're voting on poll %s." % poll_id)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #333333;"&gt;&lt;span style="font-family: Times, 'Times New Roman', serif;"&gt;&lt;span style="font-size: x-large;"&gt;&lt;span style="font-style: normal;"&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="western" style="line-height: 0.48cm; orphans: 2; widows: 2;"&gt;&lt;span style="color: #333333;"&gt;&lt;span style="font-family: Times, 'Times New Roman', serif;"&gt;&lt;span style="font-size: x-large;"&gt;&lt;span style="font-style: normal;"&gt;&lt;b&gt;Write views that actually do something&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="western" style="line-height: 0.48cm; orphans: 2; widows: 2;"&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="color: #333333; font-family: Times, 'Times New Roman', serif;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #333333; font-family: Times, 'Times New Roman', serif;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #333333; font-family: Times, 'Times New Roman', serif;"&gt;&lt;div align="LEFT" style="margin-bottom: 0cm;"&gt;&lt;span style="color: #333333;"&gt;&lt;span style="font-family: 'Times New Roman', serif;"&gt;&lt;span style="font-style: normal;"&gt;&lt;span style="font-weight: normal;"&gt;Eachview is responsible for doing one of two things: Returning an&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;tt class="western"&gt;&lt;span style="color: #d52a33;"&gt;&lt;span style="text-decoration: none;"&gt;&lt;span style="font-family: 'Times New Roman', serif;"&gt;&lt;span style="font-style: normal;"&gt;&lt;span style="font-weight: normal;"&gt;&lt;a href="http://docs.djangoproject.com/en/1.2/ref/request-response/#django.http.HttpResponse"&gt;HttpResponse&lt;/a&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/tt&gt;&lt;span style="color: #333333;"&gt;&lt;span style="font-family: 'Times New Roman', serif;"&gt;&lt;span style="font-style: normal;"&gt;&lt;span style="font-weight: normal;"&gt;object containing thecontent for the requested page, or raising an exception&lt;br /&gt;such as &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;tt class="western"&gt;&lt;span style="color: #333333;"&gt;&lt;span style="font-family: 'Times New Roman', serif;"&gt;&lt;span style="font-style: normal;"&gt;&lt;span style="font-weight: normal;"&gt;Http404&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/tt&gt;&lt;span style="color: #333333;"&gt;&lt;span style="font-family: 'Times New Roman', serif;"&gt;&lt;span style="font-style: normal;"&gt;&lt;span style="font-weight: normal;"&gt;.&lt;br /&gt;The rest is up to you.\Your view can read records from a database, or not. It can use a  template system&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #333333;"&gt;&lt;span style="font-family: 'Times New Roman', serif;"&gt;&lt;span style="font-style: normal;"&gt;&lt;span style="font-weight: normal;"&gt;such as Django's -- or&amp;nbsp; a third-party Python template system -- or  not. It can generate a PDF&lt;br /&gt;file, output XML, create a ZIP file&amp;nbsp; on the fly,&amp;nbsp; anything you want,&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #333333;"&gt;&lt;span style="font-family: 'Times New Roman', serif;"&gt;&lt;span style="font-style: normal;"&gt;&lt;span style="font-weight: normal;"&gt;using whatever Python libraries you want.All Django wants is that &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;tt class="western"&gt;&lt;a href="http://docs.djangoproject.com/en/1.2/ref/request-response/#django.http.HttpResponse"&gt;&lt;span style="color: #d52a33;"&gt;&lt;span style="text-decoration: none;"&gt;&lt;span style="font-family: 'Times New Roman', serif;"&gt;&lt;span style="font-style: normal;"&gt;&lt;span style="font-weight: normal;"&gt;HttpResponse&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;&lt;/tt&gt;&lt;span style="color: #333333;"&gt;&lt;span style="font-family: 'Times New Roman', serif;"&gt;&lt;span style="font-style: normal;"&gt;&lt;span style="font-weight: normal;"&gt;.&lt;br /&gt; Or an exception.Because it's convenient, let's use Django's&lt;br /&gt;own&amp;nbsp;database API,&amp;nbsp; which  we covered in. Here's one stab at the &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;tt class="western"&gt;&lt;span style="color: #333333;"&gt;&lt;span style="font-family: 'Times New Roman', serif;"&gt;&lt;span style="font-style: normal;"&gt;&lt;span style="font-weight: normal;"&gt;index() &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/tt&gt;&lt;span style="color: #333333;"&gt;&lt;span style="font-family: 'Times New Roman', serif;"&gt;&lt;span style="font-style: normal;"&gt;&lt;span style="font-weight: normal;"&gt;view,&lt;br /&gt;which displays the latest 5 poll questions in the system, separated&lt;br /&gt;by commas,&amp;nbsp; according to publication date:&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align="LEFT"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;from django.template import Context, loader&lt;/span&gt;&lt;/div&gt;&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;pre class="western" style="line-height: 0.48cm; orphans: 2; widows: 2;"&gt;&lt;span style="color: #333333;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;from mysite.polls.models import Poll&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: #333333;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;from django.http import HttpResponse&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: #333333;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;def index(request):&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: #333333;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;    &lt;/span&gt;&lt;span style="font-style: normal;"&gt;&lt;span style="font-weight: normal;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;latest_poll_list = Poll.objects.all().order_by('-pub_date')[:5]&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: #333333;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;    &lt;/span&gt;&lt;span style="font-style: normal;"&gt;&lt;span style="font-weight: normal;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;t = loader.get_template('polls/index.html')&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: #333333;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;    &lt;/span&gt;&lt;span style="font-style: normal;"&gt;&lt;span style="font-weight: normal;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;c = Context({&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: #333333;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;        &lt;/span&gt;&lt;span style="font-style: normal;"&gt;&lt;span style="font-weight: normal;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;'latest_poll_list': latest_poll_list,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: #333333;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;    &lt;/span&gt;&lt;span style="font-style: normal;"&gt;&lt;span style="font-weight: normal;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;})&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: #333333;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;    &lt;/span&gt;&lt;span style="font-style: normal;"&gt;&lt;span style="font-weight: normal;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;return HttpResponse(t.render(c))&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: #333333;"&gt;&lt;span style="font-family: Times, 'Times New Roman', serif;"&gt;&lt;span style="font-style: normal;"&gt;&lt;span style="font-weight: normal;"&gt;That code loads the template called "polls/index.html" and passes it a context.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #333333;"&gt;&lt;span style="font-family: Times, 'Times New Roman', serif;"&gt;The context is a dictionary mapping template variable names to Python  objects.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #333333;"&gt;&lt;span style="font-family: Times, 'Times New Roman', serif;"&gt;&lt;span style="font-style: normal;"&gt;&lt;span style="font-weight: normal;"&gt;Reload the page. Now you'll see an error:&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: #333333;"&gt;&lt;span style="font-style: normal;"&gt;&lt;span style="font-weight: normal;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;TemplateDoesNotExist at /polls/&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: #333333;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;polls/index.html&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #333333;"&gt;&lt;span style="font-family: Times, 'Times New Roman', serif;"&gt;&lt;span style="font-style: normal;"&gt;&lt;span style="font-weight: normal;"&gt;There's no template yet. First, create a directory, somewhere on your filesystem, whose contents&lt;br /&gt;Django can access. (Django runs as whatever user your server runs.) Don't put them under your&amp;nbsp;&lt;br /&gt;document root, though. You probably shouldn't make them public, just for security's sake. Then edit &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;tt class="western"&gt;&lt;span style="color: #d52a33;"&gt;&lt;span style="text-decoration: none;"&gt;&lt;span style="font-family: Times, 'Times New Roman', serif;"&gt;&lt;span style="font-style: normal;"&gt;&lt;span style="font-weight: normal;"&gt;&lt;a href="http://docs.djangoproject.com/en/1.2/ref/settings/#setting-TEMPLATE_DIRS"&gt;TEMPLATE_DIRS&lt;/a&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/tt&gt;&lt;/pre&gt;&lt;pre class="western" style="line-height: 0.48cm; orphans: 2; widows: 2;"&gt;&lt;tt class="western"&gt;&lt;span style="color: #d52a33;"&gt;&lt;span style="text-decoration: none;"&gt;&lt;span style="font-family: Times, 'Times New Roman', serif;"&gt;&lt;span style="font-style: normal;"&gt;&lt;span style="font-weight: normal;"&gt;&lt;a href="http://docs.djangoproject.com/en/1.2/ref/settings/#setting-TEMPLATE_DIRS"&gt;&lt;/a&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/tt&gt;&lt;tt class="western"&gt;&lt;span style="color: #333333;"&gt;&lt;span style="font-family: Times, 'Times New Roman', serif;"&gt;&lt;span style="font-style: normal;"&gt;&lt;span style="font-weight: normal;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/tt&gt;&lt;span style="color: #333333;"&gt;&lt;span style="font-family: Times, 'Times New Roman', serif;"&gt;&lt;span style="font-style: normal;"&gt;&lt;span style="font-weight: normal;"&gt;in your &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;tt class="western"&gt;&lt;span style="color: #333333;"&gt;&lt;span style="font-family: Times, 'Times New Roman', serif;"&gt;&lt;span style="font-style: normal;"&gt;&lt;span style="font-weight: normal;"&gt;settings.py &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/tt&gt;&lt;span style="color: #333333;"&gt;&lt;span style="font-family: Times, 'Times New Roman', serif;"&gt;&lt;span style="font-style: normal;"&gt;&lt;span style="font-weight: normal;"&gt;to tell Django where it can find templates -- just&amp;nbsp; as you did in the "Customize the admin look and&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="western" style="line-height: 0.48cm; orphans: 2; widows: 2;"&gt;&lt;span style="color: #333333;"&gt;&lt;span style="font-family: Times, 'Times New Roman', serif;"&gt;&lt;span style="font-style: normal;"&gt;&lt;span style="font-weight: normal;"&gt;feel" .&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="western" style="line-height: 0.48cm; orphans: 2; widows: 2;"&gt;&lt;span style="color: #333333;"&gt;&lt;span style="font-family: Times, 'Times New Roman', serif;"&gt;&lt;span style="font-style: normal;"&gt;&lt;span style="font-weight: normal;"&gt; When you've done that, create a directory &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;tt class="western"&gt;&lt;span style="color: #333333;"&gt;&lt;span style="font-family: Times, 'Times New Roman', serif;"&gt;&lt;span style="font-style: normal;"&gt;&lt;span style="font-weight: normal;"&gt;polls&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/tt&gt;&lt;span style="color: #333333;"&gt;&lt;span style="font-family: Times, 'Times New Roman', serif;"&gt;&lt;span style="font-style: normal;"&gt;&lt;span style="font-weight: normal;"&gt; in your template directory. Within that, create a file called &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;tt class="western"&gt;&lt;span style="color: #333333;"&gt;&lt;span style="font-family: Times, 'Times New Roman', serif;"&gt;&lt;span style="font-style: normal;"&gt;&lt;span style="font-weight: normal;"&gt;index.html&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/tt&gt;&lt;span style="color: #333333;"&gt;&lt;span style="font-family: Times, 'Times New Roman', serif;"&gt;&lt;span style="font-style: normal;"&gt;&lt;span style="font-weight: normal;"&gt;.&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="western" style="line-height: 0.48cm; orphans: 2; widows: 2;"&gt;&lt;span style="color: #333333;"&gt;&lt;span style="font-family: Times, 'Times New Roman', serif;"&gt;&lt;span style="font-style: normal;"&gt;&lt;span style="font-weight: normal;"&gt;Note that our &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;tt class="western"&gt;&lt;span style="color: #333333;"&gt;&lt;span style="font-family: Times, 'Times New Roman', serif;"&gt;&lt;span style="font-style: normal;"&gt;&lt;span style="font-weight: normal;"&gt;loader.get_template('polls/index.html') &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/tt&gt;&lt;span style="color: #333333;"&gt;&lt;span style="font-family: Times, 'Times New Roman', serif;"&gt;&lt;span style="font-style: normal;"&gt;&lt;span style="font-weight: normal;"&gt;code from above maps to "[template_directory]/polls/index.html"&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="western" style="line-height: 0.48cm; orphans: 2; widows: 2;"&gt;&lt;span style="color: #333333;"&gt;&lt;span style="font-family: Times, 'Times New Roman', serif;"&gt;&lt;span style="font-style: normal;"&gt;&lt;span style="font-weight: normal;"&gt; on the filesystem. Put the following code in that template: &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #333333;"&gt;&lt;span style="font-family: Times, 'Times New Roman', serif;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="western" style="line-height: 0.48cm; orphans: 2; widows: 2;"&gt;&lt;span style="color: #333333;"&gt;&lt;span style="font-family: Times, 'Times New Roman', serif;"&gt;{% if latest_poll_list %}&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #333333;"&gt;    &lt;span style="font-family: Times, 'Times New Roman', serif;"&gt;&lt;span style="font-style: normal;"&gt;&lt;span style="font-weight: normal;"&gt;&amp;lt;ul&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #333333;"&gt;    &lt;span 
