<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
	<channel>
		<title>Angel's Blog</title>
		<link>https://angelcool.net/sphpblog/blog_index.php</link>
		<description><![CDATA[No Footer]]></description>
		<copyright>Copyright 2026, Angel</copyright>
		<managingEditor>Angel</managingEditor>
		<language>en-US</language>
		<generator>SPHPBLOG 0.7.0</generator>
		<item>
			<title>Python: Tricks, Fun &amp; More.</title>
			<link>https://angelcool.net/sphpblog/blog_index.php?entry=entry161120-022931</link>
			<description><![CDATA[Parsing a json string:<pre>&gt;&gt;&gt; import json<br />&gt;&gt;&gt; <br />&gt;&gt;&gt; jsonString = &quot;&quot;&quot;[<br />...   {&quot;firstName&quot;:&quot;John&quot;, &quot;lastName&quot;:&quot;Doe&quot;},<br />...   {&quot;firstName&quot;:&quot;Anna&quot;, &quot;lastName&quot;:&quot;Smith&quot;},<br />...   {&quot;firstName&quot;:&quot;Angel&quot;, &quot;lastName&quot;:&quot;Cool&quot;}<br />... ]&quot;&quot;&quot;<br />&gt;&gt;&gt; <br />&gt;&gt;&gt; <br />&gt;&gt;&gt; print jsonString<br />[<br />  {&quot;firstName&quot;:&quot;John&quot;, &quot;lastName&quot;:&quot;Doe&quot;},<br />  {&quot;firstName&quot;:&quot;Anna&quot;, &quot;lastName&quot;:&quot;Smith&quot;},<br />  {&quot;firstName&quot;:&quot;Angel&quot;, &quot;lastName&quot;:&quot;Cool&quot;}<br />]<br />&gt;&gt;&gt; <br />&gt;&gt;&gt; data = json.loads(jsonString)<br />&gt;&gt;&gt; <br />&gt;&gt;&gt; print data[2][&#039;firstName&#039;]<br />Angel<br />&gt;&gt;&gt; print data[2][&#039;lastName&#039;]<br />Cool<br />&gt;&gt;&gt; <br />&gt;&gt;&gt; type(data)<br />&lt;type &#039;list&#039;&gt;<br />&gt;&gt;&gt; <br />&gt;&gt;&gt; <br />&gt;&gt;&gt; for person in data:<br />...     print person[&#039;firstName&#039;] + &#039; &#039; + person[&#039;lastName&#039;]<br />... <br />John Doe<br />Anna Smith<br />Angel Cool<br />&gt;&gt;&gt; <br />&gt;&gt;&gt; data.reverse()<br />&gt;&gt;&gt; <br />&gt;&gt;&gt; for person in data:<br />...     print person[&#039;firstName&#039;] + &#039; &#039; + person[&#039;lastName&#039;]<br />... <br />Angel Cool<br />Anna Smith<br />John Doe<br />&gt;&gt;&gt; <br /></pre><br />Reversing strings:<pre>&gt;&gt;&gt; print &#039;Donald Trump&#039;[::-1]<br />pmurT dlanoD<br />&gt;&gt;&gt; print &#039;lion oil&#039;[::-1]<br />lio noil<br />&gt;&gt;&gt; print &#039;A car, a man, a maraca.&#039;[::-1]<br />.acaram a ,nam a ,rac A<br /></pre>]]></description>
			<category>- Python Notes</category>
			<guid isPermaLink="true">https://angelcool.net/sphpblog/blog_index.php?entry=entry161120-022931</guid>
			<author>Angel</author>
			<pubDate>Sun, 20 Nov 2016 02:29:31 GMT</pubDate>
		</item>
		<item>
			<title>Python: Getting started with virtualenv</title>
			<link>https://angelcool.net/sphpblog/blog_index.php?entry=entry161119-211956</link>
			<description><![CDATA[<PRE># install virutalenv<br />[aesteban@localhost ~]$ sudo pip install virtualenv<br /><br /># create virtual environment<br />[aesteban@localhost ~]$ mkdir virt_env<br />[aesteban@localhost ~]$ virtualenv virt_env/virt1 --no-site-packages<br />New python executable in /home/aesteban/virt_env/virt1/bin/python<br />Installing setuptools, pip, wheel...done.<br />[aesteban@localhost ~]$ <br /><br /># load environment<br />[aesteban@localhost ~]$ source virt_env/virt1/bin/activate<br />(virt1) [aesteban@localhost ~]$<br /><br /># deactivate environment<br />(virt1) [aesteban@localhost ~]$ deactivate<br />[aesteban@localhost ~]$ <br />[aesteban@localhost ~]$ <br /><br /># listing installed packages with yolk<br />[aesteban@localhost ~]$ sudo pip install yolk<br />[aesteban@localhost ~]$ yolk -l<br /><br /># installing yolk in our virutal environment<br />[aesteban@localhost ~]$ source virt_env/virt1/bin/activate<br />(virt1) [aesteban@localhost ~]$ pip install yolk<br />(virt1) [aesteban@localhost ~]$ yolk -l<br /><br /><br /># let&#039;s create another environment<br />(virt1) [aesteban@localhost ~]$ deactivate<br />[aesteban@localhost ~]$ virtualenv virt_env/virt2 --no-site-packages<br /><br /># let&#039;s switch back to virt1 and install Pylons and SqlAlchemy<br />(virt1) [aesteban@localhost ~]$ pip install Pylons<br />...<br />(virt1) [aesteban@localhost ~]$ pip install SqlAlchemy<br /><br /># compare virt1 and virt2 using: yolk -l</PRE><br /><br />Big shout-out to:<br /><a href="http://www.simononsoftware.com/virtualenv-tutorial/" >http://www.simononsoftware.com/virtualenv-tutorial/</a><br /><br />Thank you guys!]]></description>
			<category>- Python Notes</category>
			<guid isPermaLink="true">https://angelcool.net/sphpblog/blog_index.php?entry=entry161119-211956</guid>
			<author>Angel</author>
			<pubDate>Sat, 19 Nov 2016 21:19:56 GMT</pubDate>
		</item>
		<item>
			<title>Python 101:  Learning by doing.</title>
			<link>https://angelcool.net/sphpblog/blog_index.php?entry=entry151027-225132</link>
			<description><![CDATA[Looping through a dictionary (aka map):<br /><br />Python 2.7.5<pre>&gt;&gt;&gt; map = {50+i:i for i in range(10)}<br />&gt;&gt;&gt; map<br />{50: 0, 51: 1, 52: 2, 53: 3, 54: 4, 55: 5, 56: 6, 57: 7, 58: 8, 59: 9}<br />&gt;&gt;&gt; for key, value in map.iteritems():<br />...     print key,&#039;-&#039;,value<br />... <br />50 - 0<br />51 - 1<br />52 - 2<br />53 - 3<br />54 - 4<br />55 - 5<br />56 - 6<br />57 - 7<br />58 - 8<br />59 - 9<br />&gt;&gt;&gt;<br /></pre><br />Python 3.3.2<br /><pre>&gt;&gt;&gt; map = {50+i:i for i in range(10)}<br />&gt;&gt;&gt; map<br />{50: 0, 51: 1, 52: 2, 53: 3, 54: 4, 55: 5, 56: 6, 57: 7, 58: 8, 59: 9}<br />&gt;&gt;&gt; for key, value in map.items():<br />...  print(key,&#039; - &#039;,value)<br />... <br />50  -  0<br />51  -  1<br />52  -  2<br />53  -  3<br />54  -  4<br />55  -  5<br />56  -  6<br />57  -  7<br />58  -  8<br />59  -  9<br />&gt;&gt;&gt;  </pre><br /><br />Fetching url data:<br /><br />Python 2<br /><pre>[aesteban@localhost corpemployees-filtered]$ python<br />Python 2.7.5 (default, Apr 10 2015, 08:09:05) <br />[GCC 4.8.3 20140911 (Red Hat 4.8.3-7)] on linux2<br />Type &quot;help&quot;, &quot;copyright&quot;, &quot;credits&quot; or &quot;license&quot; for more information.<br />&gt;&gt;&gt; <br />&gt;&gt;&gt; import urllib<br />&gt;&gt;&gt; urllib.urlopen(&#039;https://graph.facebook.com/?id=http://www.barney.com&#039;).read()<br />&#039;{&quot;id&quot;:&quot;http:\\/\\/www.barney.com&quot;,&quot;shares&quot;:792}&#039;</pre><br />Python 3<br /><pre>[aesteban@localhost corpemployees-filtered]$ python3<br />Python 3.3.2 (default, Dec  4 2014, 12:49:00) <br />[GCC 4.8.3 20140911 (Red Hat 4.8.3-7)] on linux<br />Type &quot;help&quot;, &quot;copyright&quot;, &quot;credits&quot; or &quot;license&quot; for more information.<br />&gt;&gt;&gt; <br />&gt;&gt;&gt; import urllib.request<br />&gt;&gt;&gt; <br />&gt;&gt;&gt; urllib.request.urlopen(&#039;https://graph.facebook.com/?id=http://www.barney.com&#039;).read()<br />b&#039;{&quot;id&quot;:&quot;http:\\/\\/www.barney.com&quot;,&quot;shares&quot;:792}&#039;</pre>]]></description>
			<category>- Python Notes</category>
			<guid isPermaLink="true">https://angelcool.net/sphpblog/blog_index.php?entry=entry151027-225132</guid>
			<author>Angel</author>
			<pubDate>Tue, 27 Oct 2015 22:51:32 GMT</pubDate>
		</item>
	</channel>
</rss>
