<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Linux Ask! &#187; Python</title>
	<atom:link href="http://www.linuxask.com/topics/programming/python/feed" rel="self" type="application/rss+xml" />
	<link>http://www.linuxask.com</link>
	<description>Linux Ask! is a Q &#38; A web site specific for Linux related questions such as how to use common Linux commands.</description>
	<lastBuildDate>Tue, 05 May 2015 07:15:40 +0000</lastBuildDate>
	<language>en-US</language>
		<sy:updatePeriod>hourly</sy:updatePeriod>
		<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.9.1</generator>
<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
	<item>
		<title>How to assign a raw string in Python</title>
		<link>http://www.linuxask.com/questions/how-to-assign-a-raw-string-in-python</link>
		<comments>http://www.linuxask.com/questions/how-to-assign-a-raw-string-in-python#comments</comments>
		<pubDate>Sat, 26 Apr 2014 08:00:32 +0000</pubDate>
		<dc:creator><![CDATA[Linux Ask!]]></dc:creator>
				<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://www.linuxask.com/?p=4394</guid>
		<description><![CDATA[How to assign a raw string in Python Answer: In Python, if you want to assign a raw string without any character escape, you can use the following: s = r'\\foo\\\bar' print s<div class='yarpp-related-rss'>

Related posts:<ol>
<li><a href="http://www.linuxask.com/questions/how-to-modify-a-single-character-in-a-string-in-python" rel="bookmark" title="How to modify a single character in a string in Python?">How to modify a single character in a string in Python? </a></li>
<li><a href="http://www.linuxask.com/questions/how-do-i-convert-a-number-to-a-string-in-python" rel="bookmark" title="How do I convert a number to a string in Python?">How do I convert a number to a string in Python? </a></li>
<li><a href="http://www.linuxask.com/questions/multi-line-string-in-python" rel="bookmark" title="Multi-line string in Python">Multi-line string in Python </a></li>
</ol>
</div>
]]></description>
				<content:encoded><![CDATA[<p>How to assign a raw string in Python</p>
<p><strong>Answer:</strong></p>
<p>In Python, if you want to assign a raw string without any character escape, you can use the following:</p>
<pre><code>s = r'\\foo\\\bar'
print s</code></pre>
<div class='yarpp-related-rss'>
<p>Related posts:<ol>
<li><a href="http://www.linuxask.com/questions/how-to-modify-a-single-character-in-a-string-in-python" rel="bookmark" title="How to modify a single character in a string in Python?">How to modify a single character in a string in Python? </a></li>
<li><a href="http://www.linuxask.com/questions/how-do-i-convert-a-number-to-a-string-in-python" rel="bookmark" title="How do I convert a number to a string in Python?">How do I convert a number to a string in Python? </a></li>
<li><a href="http://www.linuxask.com/questions/multi-line-string-in-python" rel="bookmark" title="Multi-line string in Python">Multi-line string in Python </a></li>
</ol></p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.linuxask.com/questions/how-to-assign-a-raw-string-in-python/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to get absolute path in Python?</title>
		<link>http://www.linuxask.com/questions/how-to-get-absolute-path-in-python</link>
		<comments>http://www.linuxask.com/questions/how-to-get-absolute-path-in-python#comments</comments>
		<pubDate>Mon, 23 Jul 2012 15:44:10 +0000</pubDate>
		<dc:creator><![CDATA[Linux Ask!]]></dc:creator>
				<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://www.linuxask.com/?p=3919</guid>
		<description><![CDATA[How to get absolute path in Python? Answer: To return the absolute path when you provide shortcut path such as ".", e.g. import os print os.path.abspath(".") # print the full path of ., depending where you execute the program<div class='yarpp-related-rss'>

Related posts:<ol>
<li><a href="http://www.linuxask.com/questions/how-to-debug-in-python" rel="bookmark" title="How to debug in Python?">How to debug in Python? </a></li>
<li><a href="http://www.linuxask.com/questions/how-to-perform-syntax-check-for-python-program" rel="bookmark" title="How to perform syntax check for Python program">How to perform syntax check for Python program </a></li>
<li><a href="http://www.linuxask.com/questions/what-is-the-zen-of-python" rel="bookmark" title="What is &#8220;The Zen of Python&#8221;?">What is &#8220;The Zen of Python&#8221;? </a></li>
</ol>
</div>
]]></description>
				<content:encoded><![CDATA[<p>How to get absolute path in Python?</p>
<p><strong>Answer:</strong></p>
<p>To return the absolute path when you provide shortcut path such as ".", e.g.</p>
<pre><code>import os
print os.path.abspath(".") # print the full path of ., depending where you execute the program
</code></pre>
<div class='yarpp-related-rss'>
<p>Related posts:<ol>
<li><a href="http://www.linuxask.com/questions/how-to-debug-in-python" rel="bookmark" title="How to debug in Python?">How to debug in Python? </a></li>
<li><a href="http://www.linuxask.com/questions/how-to-perform-syntax-check-for-python-program" rel="bookmark" title="How to perform syntax check for Python program">How to perform syntax check for Python program </a></li>
<li><a href="http://www.linuxask.com/questions/what-is-the-zen-of-python" rel="bookmark" title="What is &#8220;The Zen of Python&#8221;?">What is &#8220;The Zen of Python&#8221;? </a></li>
</ol></p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.linuxask.com/questions/how-to-get-absolute-path-in-python/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Hello World in different scripting languages</title>
		<link>http://www.linuxask.com/questions/hello-world-in-different-scripting-languages</link>
		<comments>http://www.linuxask.com/questions/hello-world-in-different-scripting-languages#comments</comments>
		<pubDate>Wed, 28 Sep 2011 10:44:11 +0000</pubDate>
		<dc:creator><![CDATA[Linux Ask!]]></dc:creator>
				<category><![CDATA[Perl]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://www.linuxask.com/?p=3528</guid>
		<description><![CDATA[Print to standard output in different scripting languages Answer: To print a string of "Hello World" to the standard output in different scripting languages 1. Perl print "Hello, World!"; 2. Python print('Hello, World!') 3. PHP echo "Hello, World!"; 4. Ruby puts "Hello, World!"<div class='yarpp-related-rss'>

Related posts:<ol>
<li><a href="http://www.linuxask.com/questions/multi-line-string-in-ruby" rel="bookmark" title="Multi-line string in Ruby">Multi-line string in Ruby </a></li>
<li><a href="http://www.linuxask.com/questions/how-to-perform-syntax-check-for-python-program" rel="bookmark" title="How to perform syntax check for Python program">How to perform syntax check for Python program </a></li>
<li><a href="http://www.linuxask.com/questions/how-to-modify-a-single-character-in-a-string-in-python" rel="bookmark" title="How to modify a single character in a string in Python?">How to modify a single character in a string in Python? </a></li>
</ol>
</div>
]]></description>
				<content:encoded><![CDATA[<p>Print to standard output in different scripting languages</p>
<p><strong>Answer:</strong></p>
<p>To print a string of "<strong>Hello World</strong>" to the standard output in different scripting languages</p>
<p><strong>1. Perl<br />
</strong><br />
<code>print "Hello, World!";</code></p>
<p><strong>2. Python<br />
</strong><br />
<code>print('Hello, World!')</code></p>
<p><strong>3. PHP<br />
</strong><br />
<code>echo "Hello, World!";</code></p>
<p><strong>4. Ruby<br />
</strong><br />
<code>puts "Hello, World!"</code></p>
<div class='yarpp-related-rss'>
<p>Related posts:<ol>
<li><a href="http://www.linuxask.com/questions/multi-line-string-in-ruby" rel="bookmark" title="Multi-line string in Ruby">Multi-line string in Ruby </a></li>
<li><a href="http://www.linuxask.com/questions/how-to-perform-syntax-check-for-python-program" rel="bookmark" title="How to perform syntax check for Python program">How to perform syntax check for Python program </a></li>
<li><a href="http://www.linuxask.com/questions/how-to-modify-a-single-character-in-a-string-in-python" rel="bookmark" title="How to modify a single character in a string in Python?">How to modify a single character in a string in Python? </a></li>
</ol></p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.linuxask.com/questions/hello-world-in-different-scripting-languages/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Add Personal Package Archives (PPA) to the current repository in Ubuntu</title>
		<link>http://www.linuxask.com/questions/add-personal-package-archives-ppa-to-the-current-repository-in-ubuntu</link>
		<comments>http://www.linuxask.com/questions/add-personal-package-archives-ppa-to-the-current-repository-in-ubuntu#comments</comments>
		<pubDate>Wed, 18 May 2011 16:30:19 +0000</pubDate>
		<dc:creator><![CDATA[Linux Ask!]]></dc:creator>
				<category><![CDATA[Advanced Linux]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[Ubuntu]]></category>

		<guid isPermaLink="false">http://www.linuxask.com/?p=3014</guid>
		<description><![CDATA[Add Personal Package Archives (PPA) to the current repository in Ubuntu Answer: add-apt-repository is a helper script which adds an external APT repository to either /etc/apt/sources.list or a file in /etc/apt/sources.list.d/. It can also import the keys needed. To get this tool, just a single command: # sudo apt-get install python-software-properties That is it.<div class='yarpp-related-rss'>

Related posts:<ol>
<li><a href="http://www.linuxask.com/questions/import-files-and-directories-into-a-svn-repository" rel="bookmark" title="Import files and directories into a SVN repository">Import files and directories into a SVN repository </a></li>
<li><a href="http://www.linuxask.com/questions/update-the-package-index-in-ubuntu" rel="bookmark" title="Update the Package Index in Ubuntu">Update the Package Index in Ubuntu </a></li>
<li><a href="http://www.linuxask.com/questions/install-google-chrome-in-ubuntu" rel="bookmark" title="Install Google Chrome in Ubuntu">Install Google Chrome in Ubuntu </a></li>
</ol>
</div>
]]></description>
				<content:encoded><![CDATA[<p>Add Personal Package Archives (PPA) to the current repository in Ubuntu</p>
<p><strong>Answer:</strong></p>
<p><strong>add-apt-repository</strong> is a helper script which adds an external APT repository to either /etc/apt/sources.list or a file in /etc/apt/sources.list.d/. It can also import the keys needed.</p>
<p>To get this tool, just a single command:</p>
<p><code># sudo apt-get install python-software-properties </code></p>
<p>That is it.</p>
<div class='yarpp-related-rss'>
<p>Related posts:<ol>
<li><a href="http://www.linuxask.com/questions/import-files-and-directories-into-a-svn-repository" rel="bookmark" title="Import files and directories into a SVN repository">Import files and directories into a SVN repository </a></li>
<li><a href="http://www.linuxask.com/questions/update-the-package-index-in-ubuntu" rel="bookmark" title="Update the Package Index in Ubuntu">Update the Package Index in Ubuntu </a></li>
<li><a href="http://www.linuxask.com/questions/install-google-chrome-in-ubuntu" rel="bookmark" title="Install Google Chrome in Ubuntu">Install Google Chrome in Ubuntu </a></li>
</ol></p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.linuxask.com/questions/add-personal-package-archives-ppa-to-the-current-repository-in-ubuntu/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Render web page using PyQt</title>
		<link>http://www.linuxask.com/questions/render-web-page-using-pyqt</link>
		<comments>http://www.linuxask.com/questions/render-web-page-using-pyqt#comments</comments>
		<pubDate>Wed, 16 Mar 2011 05:10:54 +0000</pubDate>
		<dc:creator><![CDATA[Linux Ask!]]></dc:creator>
				<category><![CDATA[Debian]]></category>
		<category><![CDATA[Internet]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[Qt]]></category>
		<category><![CDATA[webkit]]></category>

		<guid isPermaLink="false">http://www.linuxask.com/?p=2860</guid>
		<description><![CDATA[Render web page using PyQt Answer: Qt bindings to WebKit have been added since 4.4, so you can use PyQt to script the browser (Webkit based). Firstly, make sure you have installed the need packages: # sudo apt-get install libqt4-core libqt4-webkit python-qt4 Then you can write a simple script to test, e.g. #!/usr/bin/env python import <a href='http://www.linuxask.com/questions/render-web-page-using-pyqt' class='excerpt-more'>[...]</a><div class='yarpp-related-rss'>

Related posts:<ol>
<li><a href="http://www.linuxask.com/questions/how-to-debug-in-python" rel="bookmark" title="How to debug in Python?">How to debug in Python? </a></li>
<li><a href="http://www.linuxask.com/questions/how-to-perform-syntax-check-for-python-program" rel="bookmark" title="How to perform syntax check for Python program">How to perform syntax check for Python program </a></li>
<li><a href="http://www.linuxask.com/questions/write-python-script-using-utf-8" rel="bookmark" title="Write Python script using utf-8">Write Python script using utf-8 </a></li>
</ol>
</div>
]]></description>
				<content:encoded><![CDATA[<p>Render web page using PyQt</p>
<p><strong>Answer:</strong></p>
<p><strong>Qt </strong>bindings to WebKit have been added since 4.4, so you can use <strong>PyQt </strong>to script the browser (<strong>Webkit </strong>based).</p>
<p>Firstly, make sure you have installed the need packages:</p>
<p><code># sudo apt-get install  libqt4-core libqt4-webkit python-qt4</code></p>
<p>Then you can write a simple script to test, e.g.</p>
<pre><code>#!/usr/bin/env python

import sys
from PyQt4.QtCore import *
from PyQt4.QtGui import *
from PyQt4.QtWebKit import *

app = QApplication(sys.argv)

web = QWebView()
web.load(QUrl("http://www.google.com"))
web.show()

sys.exit(app.exec_())
</code></pre>
<div class='yarpp-related-rss'>
<p>Related posts:<ol>
<li><a href="http://www.linuxask.com/questions/how-to-debug-in-python" rel="bookmark" title="How to debug in Python?">How to debug in Python? </a></li>
<li><a href="http://www.linuxask.com/questions/how-to-perform-syntax-check-for-python-program" rel="bookmark" title="How to perform syntax check for Python program">How to perform syntax check for Python program </a></li>
<li><a href="http://www.linuxask.com/questions/write-python-script-using-utf-8" rel="bookmark" title="Write Python script using utf-8">Write Python script using utf-8 </a></li>
</ol></p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.linuxask.com/questions/render-web-page-using-pyqt/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How do I convert a number to a string in Python?</title>
		<link>http://www.linuxask.com/questions/how-do-i-convert-a-number-to-a-string-in-python</link>
		<comments>http://www.linuxask.com/questions/how-do-i-convert-a-number-to-a-string-in-python#comments</comments>
		<pubDate>Sun, 19 Dec 2010 07:57:38 +0000</pubDate>
		<dc:creator><![CDATA[Linux Ask!]]></dc:creator>
				<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://www.linuxask.com/?p=2682</guid>
		<description><![CDATA[How do I convert a number to a string in Python? Answer: To convert a number to a string in Python, try the str() function. foo = str( 999 ); print foo + ' is a string'; Result is : 999 is a string<div class='yarpp-related-rss'>

Related posts:<ol>
<li><a href="http://www.linuxask.com/questions/convert-string-to-integer-in-python" rel="bookmark" title="Convert string to integer in Python">Convert string to integer in Python </a></li>
<li><a href="http://www.linuxask.com/questions/how-to-modify-a-single-character-in-a-string-in-python" rel="bookmark" title="How to modify a single character in a string in Python?">How to modify a single character in a string in Python? </a></li>
<li><a href="http://www.linuxask.com/questions/generate-a-random-number-in-python" rel="bookmark" title="Generate a random number in Python">Generate a random number in Python </a></li>
</ol>
</div>
]]></description>
				<content:encoded><![CDATA[<p>How do I convert a number to a string in Python?</p>
<p><strong>Answer:</strong></p>
<p>To convert a number to a string in Python, try the<strong> str()</strong> function.</p>
<pre><code>foo = str( 999 );
print foo + ' is a string';
</code></pre>
<p>Result is : </p>
<p><code>999 is a string</code></p>
<div class='yarpp-related-rss'>
<p>Related posts:<ol>
<li><a href="http://www.linuxask.com/questions/convert-string-to-integer-in-python" rel="bookmark" title="Convert string to integer in Python">Convert string to integer in Python </a></li>
<li><a href="http://www.linuxask.com/questions/how-to-modify-a-single-character-in-a-string-in-python" rel="bookmark" title="How to modify a single character in a string in Python?">How to modify a single character in a string in Python? </a></li>
<li><a href="http://www.linuxask.com/questions/generate-a-random-number-in-python" rel="bookmark" title="Generate a random number in Python">Generate a random number in Python </a></li>
</ol></p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.linuxask.com/questions/how-do-i-convert-a-number-to-a-string-in-python/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How do I find the current module name in Python?</title>
		<link>http://www.linuxask.com/questions/how-do-i-find-the-current-module-name-in-python</link>
		<comments>http://www.linuxask.com/questions/how-do-i-find-the-current-module-name-in-python#comments</comments>
		<pubDate>Sat, 18 Dec 2010 08:03:28 +0000</pubDate>
		<dc:creator><![CDATA[Linux Ask!]]></dc:creator>
				<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://www.linuxask.com/?p=2684</guid>
		<description><![CDATA[How do I find the current module name in Python? Answer: The easiest way is to look at the look at the predefined global variable __main__. If it has the value "__main__", it means the program is run as a script (not as imported module). E.g. def main(): print 'Running test...' if __name__ == '__main__': <a href='http://www.linuxask.com/questions/how-do-i-find-the-current-module-name-in-python' class='excerpt-more'>[...]</a><div class='yarpp-related-rss'>

Related posts:<ol>
<li><a href="http://www.linuxask.com/questions/how-to-debug-in-python" rel="bookmark" title="How to debug in Python?">How to debug in Python? </a></li>
<li><a href="http://www.linuxask.com/questions/how-to-find-a-perl-modules-path" rel="bookmark" title="How to find a Perl Module&#8217;s Path">How to find a Perl Module&#8217;s Path </a></li>
<li><a href="http://www.linuxask.com/questions/find-the-process-id-of-a-running-program" rel="bookmark" title="Find the process ID of a running program">Find the process ID of a running program </a></li>
</ol>
</div>
]]></description>
				<content:encoded><![CDATA[<p>How do I find the current module name in Python?</p>
<p><strong>Answer:</strong></p>
<p>The easiest way is to look at the look at the predefined global variable <strong>__main__</strong>. If it has the value "__main__", it means the program is run as a script (not as imported module).</p>
<p>E.g.</p>
<pre><code>def main():
    print 'Running test...'


if __name__ == '__main__':
    main()
</code></pre>
<div class='yarpp-related-rss'>
<p>Related posts:<ol>
<li><a href="http://www.linuxask.com/questions/how-to-debug-in-python" rel="bookmark" title="How to debug in Python?">How to debug in Python? </a></li>
<li><a href="http://www.linuxask.com/questions/how-to-find-a-perl-modules-path" rel="bookmark" title="How to find a Perl Module&#8217;s Path">How to find a Perl Module&#8217;s Path </a></li>
<li><a href="http://www.linuxask.com/questions/find-the-process-id-of-a-running-program" rel="bookmark" title="Find the process ID of a running program">Find the process ID of a running program </a></li>
</ol></p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.linuxask.com/questions/how-do-i-find-the-current-module-name-in-python/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Generate a random number in Python</title>
		<link>http://www.linuxask.com/questions/generate-a-random-number-in-python</link>
		<comments>http://www.linuxask.com/questions/generate-a-random-number-in-python#comments</comments>
		<pubDate>Thu, 28 Oct 2010 09:20:51 +0000</pubDate>
		<dc:creator><![CDATA[Linux Ask!]]></dc:creator>
				<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://www.linuxask.com/?p=2484</guid>
		<description><![CDATA[Generate a random number in Python Answer: It is very easy to generate a random number in Python, see below: import random print random.randint(1,100) The above code print a number between 1 to 100.<div class='yarpp-related-rss'>

Related posts:<ol>
<li><a href="http://www.linuxask.com/questions/generate-random-number-in-linux" rel="bookmark" title="Generate random number in Linux">Generate random number in Linux </a></li>
<li><a href="http://www.linuxask.com/questions/generate-random-number-in-perl" rel="bookmark" title="Generate random number in Perl">Generate random number in Perl </a></li>
<li><a href="http://www.linuxask.com/questions/generate-random-data-in-mongodb" rel="bookmark" title="Generate random data in MongoDB">Generate random data in MongoDB </a></li>
</ol>
</div>
]]></description>
				<content:encoded><![CDATA[<p>Generate a random number in Python</p>
<p><strong>Answer:</strong></p>
<p>It is very easy to generate a  random number in <strong>Python</strong>, see below:</p>
<pre><code>import random

print random.randint(1,100)
</code></pre>
<p>The above code print a number between 1 to 100.</p>
<div class='yarpp-related-rss'>
<p>Related posts:<ol>
<li><a href="http://www.linuxask.com/questions/generate-random-number-in-linux" rel="bookmark" title="Generate random number in Linux">Generate random number in Linux </a></li>
<li><a href="http://www.linuxask.com/questions/generate-random-number-in-perl" rel="bookmark" title="Generate random number in Perl">Generate random number in Perl </a></li>
<li><a href="http://www.linuxask.com/questions/generate-random-data-in-mongodb" rel="bookmark" title="Generate random data in MongoDB">Generate random data in MongoDB </a></li>
</ol></p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.linuxask.com/questions/generate-a-random-number-in-python/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Multi-line string in Python</title>
		<link>http://www.linuxask.com/questions/multi-line-string-in-python</link>
		<comments>http://www.linuxask.com/questions/multi-line-string-in-python#comments</comments>
		<pubDate>Mon, 25 Oct 2010 03:39:14 +0000</pubDate>
		<dc:creator><![CDATA[Linux Ask!]]></dc:creator>
				<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://www.linuxask.com/?p=2120</guid>
		<description><![CDATA[Multi-line string in Python Answer: In Python, multi-line string are enclosed in triple double (or single) quotes: E.g. s = """Line1 Line2 Line3""" print s Or s = '''Line1 Line2 Line3''' print s Both methods are valid.<div class='yarpp-related-rss'>

Related posts:<ol>
<li><a href="http://www.linuxask.com/questions/multi-line-string-in-perl" rel="bookmark" title="Multi-line string in Perl">Multi-line string in Perl </a></li>
<li><a href="http://www.linuxask.com/questions/multi-line-string-in-ruby" rel="bookmark" title="Multi-line string in Ruby">Multi-line string in Ruby </a></li>
<li><a href="http://www.linuxask.com/questions/multi-line-string-in-php" rel="bookmark" title="Multi-line string in PHP">Multi-line string in PHP </a></li>
</ol>
</div>
]]></description>
				<content:encoded><![CDATA[<p>Multi-line string in Python</p>
<p><strong>Answer:</strong></p>
<p>In <strong>Python</strong>,  multi-line string  are enclosed in triple double (or single) quotes:</p>
<p>E.g.</p>
<pre><code>s = """Line1
Line2
Line3"""

print s
</code></pre>
<p>Or </p>
<pre><code>s = '''Line1
Line2
Line3'''

print s
</code></pre>
<p>Both methods are valid.</p>
<div class='yarpp-related-rss'>
<p>Related posts:<ol>
<li><a href="http://www.linuxask.com/questions/multi-line-string-in-perl" rel="bookmark" title="Multi-line string in Perl">Multi-line string in Perl </a></li>
<li><a href="http://www.linuxask.com/questions/multi-line-string-in-ruby" rel="bookmark" title="Multi-line string in Ruby">Multi-line string in Ruby </a></li>
<li><a href="http://www.linuxask.com/questions/multi-line-string-in-php" rel="bookmark" title="Multi-line string in PHP">Multi-line string in PHP </a></li>
</ol></p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.linuxask.com/questions/multi-line-string-in-python/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to modify a single character in a string in Python?</title>
		<link>http://www.linuxask.com/questions/how-to-modify-a-single-character-in-a-string-in-python</link>
		<comments>http://www.linuxask.com/questions/how-to-modify-a-single-character-in-a-string-in-python#comments</comments>
		<pubDate>Wed, 20 Oct 2010 09:05:41 +0000</pubDate>
		<dc:creator><![CDATA[Linux Ask!]]></dc:creator>
				<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://www.linuxask.com/?p=2440</guid>
		<description><![CDATA[How to modify a single character in a string in Python? Answer: Strings in Python are immutable, if you want to modify a single character in a string in Python, you need to do something like the following... a = list("foo") a[2] = 'x' print ''.join(a) The string "fox " will be printed out.<div class='yarpp-related-rss'>

Related posts:<ol>
<li><a href="http://www.linuxask.com/questions/multi-line-string-in-python" rel="bookmark" title="Multi-line string in Python">Multi-line string in Python </a></li>
<li><a href="http://www.linuxask.com/questions/how-do-i-convert-a-number-to-a-string-in-python" rel="bookmark" title="How do I convert a number to a string in Python?">How do I convert a number to a string in Python? </a></li>
<li><a href="http://www.linuxask.com/questions/remove-the-last-character-of-a-string-in-perl" rel="bookmark" title="Remove the last character of a string in Perl">Remove the last character of a string in Perl </a></li>
</ol>
</div>
]]></description>
				<content:encoded><![CDATA[<p>How to modify a single character in a string in Python?</p>
<p><strong>Answer:</strong></p>
<p>Strings in Python are immutable, if you want to modify a single character in a string in Python, you need to do something like the following...</p>
<pre><code>a = list("foo")
a[2] = 'x'
print ''.join(a)
</code></pre>
<p>The string "<strong>fox </strong>" will be printed out.</p>
<div class='yarpp-related-rss'>
<p>Related posts:<ol>
<li><a href="http://www.linuxask.com/questions/multi-line-string-in-python" rel="bookmark" title="Multi-line string in Python">Multi-line string in Python </a></li>
<li><a href="http://www.linuxask.com/questions/how-do-i-convert-a-number-to-a-string-in-python" rel="bookmark" title="How do I convert a number to a string in Python?">How do I convert a number to a string in Python? </a></li>
<li><a href="http://www.linuxask.com/questions/remove-the-last-character-of-a-string-in-perl" rel="bookmark" title="Remove the last character of a string in Perl">Remove the last character of a string in Perl </a></li>
</ol></p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.linuxask.com/questions/how-to-modify-a-single-character-in-a-string-in-python/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
