<?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>Python hacks Archives - Be on the Right Side of Change</title>
	<atom:link href="https://blog.finxter.com/tag/python-hacks/feed/" rel="self" type="application/rss+xml" />
	<link>https://blog.finxter.com/tag/python-hacks/</link>
	<description></description>
	<lastBuildDate>Wed, 08 Jul 2020 19:17:55 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>

<image>
	<url>https://blog.finxter.com/wp-content/uploads/2020/08/cropped-cropped-finxter_nobackground-32x32.png</url>
	<title>Python hacks Archives - Be on the Right Side of Change</title>
	<link>https://blog.finxter.com/tag/python-hacks/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Python Functions and Tricks Cheat Sheet</title>
		<link>https://blog.finxter.com/python-cheat-sheet-functions-and-tricks/</link>
					<comments>https://blog.finxter.com/python-cheat-sheet-functions-and-tricks/#respond</comments>
		
		<dc:creator><![CDATA[Chris]]></dc:creator>
		<pubDate>Mon, 22 Jun 2020 10:21:00 +0000</pubDate>
				<category><![CDATA[Cheat Sheets]]></category>
		<category><![CDATA[Computer Science]]></category>
		<category><![CDATA[Productivity]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[Python One-Liners]]></category>
		<category><![CDATA[cheat sheet]]></category>
		<category><![CDATA[Python 3]]></category>
		<category><![CDATA[python cheat sheet]]></category>
		<category><![CDATA[Python functions]]></category>
		<category><![CDATA[Python hacks]]></category>
		<category><![CDATA[Python tricks]]></category>
		<guid isPermaLink="false">https://blog.finxter.com/?p=449</guid>

					<description><![CDATA[<p>Python cheat sheets are the 80/20 principle applied to coding: learn 80% of the language features in 20% of the time.Download and pin this cheat sheet to your wall until you feel confident using all these tricks. Download PDF for Printing Try It Yourself: Exercise: Modify each function and play with the output! Here&#8217;s the ... <a title="Python Functions and Tricks Cheat Sheet" class="read-more" href="https://blog.finxter.com/python-cheat-sheet-functions-and-tricks/" aria-label="Read more about Python Functions and Tricks Cheat Sheet">Read more</a></p>
<p>The post <a href="https://blog.finxter.com/python-cheat-sheet-functions-and-tricks/">Python Functions and Tricks Cheat Sheet</a> appeared first on <a href="https://blog.finxter.com">Be on the Right Side of Change</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>Python cheat sheets are the 80/20 principle applied to coding: learn 80% of the language features in 20% of the time.<br>Download and pin this cheat sheet to your wall until you feel confident using all these tricks. <br><a href="https://blog.finxter.com/wp-content/uploads/2018/07/CheatSheet-Python-5-Functions-and-Tricks.pdf" target="_blank" rel="noreferrer noopener" title="https://blog.finxter.com/wp-content/uploads/2018/07/CheatSheet-Python-5-Functions-and-Tricks.pdf"><img decoding="async" src="https://blog.finxter.com/wp-content/uploads/2018/07/CheatSheet-Python-5-Functions-and-Tricks-791x1024.png" alt="CheatSheet Python 5 - Functions and Tricks" style="width: undefinedpx;"></a><br><a href="https://blog.finxter.com/wp-content/uploads/2018/07/CheatSheet-Python-5-Functions-and-Tricks.pdf" target="_blank" rel="noreferrer noopener"><br>Download PDF for Printing</a></p>






<p><strong>Try It Yourself:</strong></p>



<iframe src="https://trinket.io/embed/python/dab44ebcf3" marginwidth="0" marginheight="0" allowfullscreen="" width="100%" height="800" frameborder="0"></iframe>



<p><em><strong>Exercise</strong>: Modify each function and play with the output!</em></p>



<p>Here&#8217;s the code for copy&amp;paste:</p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group=""># 1. map(func, iter)
m = map(lambda x: x[0], ['red', 'green', 'blue'])
print(list(m))
# ['r', 'g', 'b']


# 2. map(func, i1, ...,ik)
l1 = [0, 2, 2]
l2 = ['apple', 'orange', 'banana']
m = map(lambda x, y: str(x) + ' ' + str(y) + 's', l1, l2)
print(list(m))
# ['0 apples', '2 oranges', '2 bananas']


# 3. string.join(iter)
print(' marries '.join(['Alice', 'Bob']))
# Alice marries Bob


# 4. filter(func, iterable)
print(list(filter(lambda x: x>17, [1, 15, 17, 18])))
# [18]


# 5. string.strip()
print("    \n   \t  42  \t ".strip())
# 42


# 6. sorted(iter)
print(sorted([8, 3, 2, 42, 5]))
# [2, 3, 5, 8, 42]


# 7. sorted(iter, key=key)
print(sorted([8, 3, 2, 42, 5], key=lambda x: 0 if x==42 else x))
# [42, 2, 3, 5, 8]


# 8. help(func)
help(str.upper)
'''
Help on method_descriptor:

upper(self, /)
    Return a copy of the string converted to uppercase.
'''


# 9. zip(i1, i2, ...)
print(list(zip(['Alice', 'Anna'], ['Bob', 'Jon', 'Frank'])))
# [('Alice', 'Bob'), ('Anna', 'Jon')]


# 10. Unzip
print(list(zip(*[('Alice', 'Bob'), ('Anna', 'Jon')])))
# [('Alice', 'Anna'), ('Bob', 'Jon')]


# 11. Enumerate
print(list(enumerate(['Alice', 'Bob', 'Jon'])))
# [(0, 'Alice'), (1, 'Bob'), (2, 'Jon')]
</pre>



<p>The following tutorials address those functions in great detail (including videos on the most important functions).</p>



<p><strong>Related Articles:</strong></p>



<ul class="wp-block-list"><li><a href="https://blog.finxter.com/daily-python-puzzle-string-encrpytion-ord-function-map-function/" title="Mastering the Python Map Function [+Video]" target="_blank" rel="noreferrer noopener">Map Function</a></li><li><a href="https://blog.finxter.com/python-join-list/" title="Python Join List [Ultimate Guide]" target="_blank" rel="noreferrer noopener">String Join</a></li><li><a href="https://blog.finxter.com/how-to-filter-a-list-in-python/" title="How to Filter a List in Python?" target="_blank" rel="noreferrer noopener">Filtering Lists</a></li><li><a href="https://blog.finxter.com/python-trim-string/" title="Python Trim String [Ultimate Guide]" target="_blank" rel="noreferrer noopener">Strip and Trim</a> </li><li><a href="https://blog.finxter.com/python-list-sort/" title="Python List sort() – The Ultimate Guide" target="_blank" rel="noreferrer noopener">Python Sorting</a></li><li><a href="https://blog.finxter.com/zip-unzip-python/" title="Zip &amp; Unzip: How Does It Work in Python?" target="_blank" rel="noreferrer noopener">Zip and Unzip</a></li></ul>



<figure class="wp-block-embed-youtube wp-block-embed is-type-video is-provider-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio"><div class="wp-block-embed__wrapper">
<iframe title="Zip &amp; Unzip: How Does It Work in Python?" width="937" height="527" src="https://www.youtube.com/embed/7zx603xCri4?feature=oembed" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe>
</div></figure>



<p>Know someone who would benefit from this cheat sheet? Share it with your friends!</p>



<p><a href="https://blog.finxter.com/subscribe/" target="_blank" rel="noreferrer noopener" title="Subscribe">Simplify learning Python and register for the free 5x Python cheat sheet course.</a></p>



<div class="wp-block-group"><div class="wp-block-group__inner-container is-layout-flow wp-block-group-is-layout-flow">
<p><strong>Related Articles:</strong></p>



<ul class="wp-block-list"><li><a href="https://blog.finxter.com/collection-5-cheat-sheets-every-python-coder-must-own/" target="_blank" rel="noreferrer noopener" title="[Collection] 11 Python Cheat Sheets Every Python Coder Must Own">[Collection] 11 Python Cheat Sheets Every Python Coder Must Own</a></li><li><a href="https://blog.finxter.com/object-oriented-programming-terminology-cheat-sheet/" target="_blank" rel="noreferrer noopener" title="https://blog.finxter.com/object-oriented-programming-terminology-cheat-sheet/">[Python OOP Cheat Sheet] A Simple Overview of Object-Oriented Programming</a></li><li><a href="https://blog.finxter.com/machine-learning-cheat-sheets/" title="[Collection] 15 Mind-Blowing Machine Learning Cheat Sheets to Pin to Your Toilet Wall" target="_blank" rel="noreferrer noopener">[Collection] 15 Mind-Blowing Machine Learning Cheat Sheets to Pin to Your Toilet Wall</a></li><li><a href="https://blog.finxter.com/python-cheat-sheets/" title="https://blog.finxter.com/python-cheat-sheets/" target="_blank" rel="noreferrer noopener">Your 8+ Free Python Cheat Sheet [Course]</a></li><li><a href="https://blog.finxter.com/python-cheat-sheet/" target="_blank" rel="noreferrer noopener" title="Python Beginner Cheat Sheet: 19 Keywords Every Coder Must Know">Python Beginner Cheat Sheet: 19 Keywords Every Coder Must Know</a></li><li><a href="https://blog.finxter.com/python-cheat-sheet-functions-and-tricks/" title="Python Functions and Tricks Cheat Sheet" target="_blank" rel="noreferrer noopener">Python Functions and Tricks Cheat Sheet</a></li><li><a href="https://blog.finxter.com/python-interview-questions/" target="_blank" rel="noreferrer noopener" title="https://blog.finxter.com/python-interview-questions/">Python Cheat Sheet: 14 Interview Questions</a></li><li><a href="https://blog.finxter.com/pandas-cheat-sheets/" title="[PDF Collection] 7 Beautiful Pandas Cheat Sheets — Post Them to Your Wall" target="_blank" rel="noreferrer noopener">Beautiful Pandas Cheat Sheets</a></li><li><a href="https://blog.finxter.com/collection-10-best-numpy-cheat-sheets-every-python-coder-must-own/" title="[Collection] 10 Best NumPy Cheat Sheets Every Python Coder Must Own" target="_blank" rel="noreferrer noopener">10 Best NumPy Cheat Sheets</a></li><li><a href="https://blog.finxter.com/python-list-methods-cheat-sheet-instant-pdf-download/" title="Python List Methods Cheat Sheet [Instant PDF Download]" target="_blank" rel="noreferrer noopener">Python List Methods Cheat Sheet [Instant PDF Download]</a></li><li><a href="https://blog.finxter.com/cheat-sheet-6-pillar-machine-learning-algorithms/" target="_blank" rel="noreferrer noopener" title="[Cheat Sheet] 6 Pillar Machine Learning Algorithms">[Cheat Sheet] 6 Pillar Machine Learning Algorithms</a></li></ul>
</div></div>
<p>The post <a href="https://blog.finxter.com/python-cheat-sheet-functions-and-tricks/">Python Functions and Tricks Cheat Sheet</a> appeared first on <a href="https://blog.finxter.com">Be on the Right Side of Change</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.finxter.com/python-cheat-sheet-functions-and-tricks/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>

<!--
Performance optimized by W3 Total Cache. Learn more: https://www.boldgrid.com/w3-total-cache/?utm_source=w3tc&utm_medium=footer_comment&utm_campaign=free_plugin

Page Caching using Disk: Enhanced 
Minified using Disk

Served from: blog.finxter.com @ 2026-06-26 19:34:02 by W3 Total Cache
-->