<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[RSS Feed]]></title><description><![CDATA[RSS Feed]]></description><link>http://direct.ecency.com</link><image><url>http://direct.ecency.com/logo512.png</url><title>RSS Feed</title><link>http://direct.ecency.com</link></image><generator>RSS for Node</generator><lastBuildDate>Wed, 22 Apr 2026 10:30:35 GMT</lastBuildDate><atom:link href="http://direct.ecency.com/created/pytricks/rss.xml" rel="self" type="application/rss+xml"/><item><title><![CDATA[Python Tricks #29 - Python's built-in HTTP server]]></title><description><![CDATA[Serve current folder by simply running python command. # Python has a HTTP server built into the # standard library. This is super handy for # previewing websites. # Python 3.x $ python3 -m http.server]]></description><link>http://direct.ecency.com/programming/@boyanpro/python-tricks-29-python-s-built-in-http-server</link><guid isPermaLink="true">http://direct.ecency.com/programming/@boyanpro/python-tricks-29-python-s-built-in-http-server</guid><category><![CDATA[programming]]></category><dc:creator><![CDATA[boyanpro]]></dc:creator><pubDate>Wed, 22 May 2019 16:07:30 GMT</pubDate></item><item><title><![CDATA[Python Tricks #28 - Use dicts as switch/case]]></title><description><![CDATA[If you ever wondered how to do switch in Python, here is your answer. # Because Python has first-class functions they can # be used to emulate switch/case statements def dispatch_if(operator, x, y): if]]></description><link>http://direct.ecency.com/programming/@boyanpro/python-tricks-28-use-dicts-as-switch-case</link><guid isPermaLink="true">http://direct.ecency.com/programming/@boyanpro/python-tricks-28-use-dicts-as-switch-case</guid><category><![CDATA[programming]]></category><dc:creator><![CDATA[boyanpro]]></dc:creator><pubDate>Sun, 19 May 2019 13:23:09 GMT</pubDate></item><item><title><![CDATA[Python Tricks #27 - f-strings Python3.6+]]></title><description><![CDATA[# f-strings are flexible way to do string interpolation available in Python 3.6+ # The old way with "format": user = "Jane Doe" action = "buy" log_message = 'User {} has logged]]></description><link>http://direct.ecency.com/programming/@boyanpro/python-tricks-27-f-strings-python3-6</link><guid isPermaLink="true">http://direct.ecency.com/programming/@boyanpro/python-tricks-27-f-strings-python3-6</guid><category><![CDATA[programming]]></category><dc:creator><![CDATA[boyanpro]]></dc:creator><pubDate>Wed, 15 May 2019 06:41:51 GMT</pubDate></item><item><title><![CDATA[Python Tricks #26 - Your Dict Size]]></title><description><![CDATA[# Empty dict size. >>> d = {} >>> import sys >>> sys.getsizeof(d) 240 # It's the same size for first eight slots for key-value pairs. # sys.getsizeof returns size of the data]]></description><link>http://direct.ecency.com/programming/@boyanpro/python-tricks-26-your-dict-size</link><guid isPermaLink="true">http://direct.ecency.com/programming/@boyanpro/python-tricks-26-your-dict-size</guid><category><![CDATA[programming]]></category><dc:creator><![CDATA[boyanpro]]></dc:creator><pubDate>Tue, 14 May 2019 22:06:18 GMT</pubDate></item><item><title><![CDATA[Python Tricks #25 - Functions Superiority]]></title><description><![CDATA[# Functions are first-class citizens in Python: # They can be passed as arguments to other functions, # returned as values from other functions, and # assigned to variables and stored in data structures.]]></description><link>http://direct.ecency.com/programming/@boyanpro/python-tricks-25-functions-superiority</link><guid isPermaLink="true">http://direct.ecency.com/programming/@boyanpro/python-tricks-25-functions-superiority</guid><category><![CDATA[programming]]></category><dc:creator><![CDATA[boyanpro]]></dc:creator><pubDate>Mon, 13 May 2019 08:08:33 GMT</pubDate></item><item><title><![CDATA[Python Tricks #24 - Taking a string input]]></title><description><![CDATA[# For example "1 2 3 4" and return [1, 2, 3, 4] # Remember list being returned has integers in it. # Don't use more than one line of code. >>> result = map(lambda x:int(x)]]></description><link>http://direct.ecency.com/programming/@boyanpro/python-tricks-24-taking-a-string-input</link><guid isPermaLink="true">http://direct.ecency.com/programming/@boyanpro/python-tricks-24-taking-a-string-input</guid><category><![CDATA[programming]]></category><dc:creator><![CDATA[boyanpro]]></dc:creator><pubDate>Fri, 10 May 2019 05:57:00 GMT</pubDate></item><item><title><![CDATA[Python Tricks #23 - is vs ==]]></title><description><![CDATA[# "is" vs "==" >>> a = [1, 2, 3] >>> b = a >>> a is b True >>> a == b True >>> c = list(a) >>> a == c True >>> a is c]]></description><link>http://direct.ecency.com/programming/@boyanpro/python-tricks-23</link><guid isPermaLink="true">http://direct.ecency.com/programming/@boyanpro/python-tricks-23</guid><category><![CDATA[programming]]></category><dc:creator><![CDATA[boyanpro]]></dc:creator><pubDate>Wed, 08 May 2019 07:02:42 GMT</pubDate></item><item><title><![CDATA[Python Tricks #22 - Dict Tricks]]></title><description><![CDATA[# Inverting a dictionary using zip >>> m = {'a': 1, 'b': 2, 'c': 3, 'd': 4} >>> m.items() [('a', 1), ('c', 3), ('b', 2), ('d', 4)] >>> zip(m.values(), m.keys()) [(1, 'a'), (3,]]></description><link>http://direct.ecency.com/programming/@boyanpro/python-tricks-22-dict-tricks</link><guid isPermaLink="true">http://direct.ecency.com/programming/@boyanpro/python-tricks-22-dict-tricks</guid><category><![CDATA[programming]]></category><dc:creator><![CDATA[boyanpro]]></dc:creator><pubDate>Wed, 08 May 2019 06:46:39 GMT</pubDate></item><item><title><![CDATA[Python Tricks #21 - Manipulating Lists]]></title><description><![CDATA[# Negative indexing >>> a = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10] >>> a[-1] 10 >>> a[-3] 8 # List slices (a[start:end]) >>> a = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10] >>>]]></description><link>http://direct.ecency.com/programming/@boyanpro/python-tricks-21-manipulating-lists</link><guid isPermaLink="true">http://direct.ecency.com/programming/@boyanpro/python-tricks-21-manipulating-lists</guid><category><![CDATA[programming]]></category><dc:creator><![CDATA[boyanpro]]></dc:creator><pubDate>Tue, 07 May 2019 06:49:09 GMT</pubDate></item><item><title><![CDATA[Python Tricks #20 - Unpacking]]></title><description><![CDATA[>>> a, b, c = 1, 2, 3 >>> a, b, c (1, 2, 3) >>> a, b, c = [1, 2, 3] >>> a, b, c (1, 2, 3) >>> a, b, c = (2 * i + 1 for i in range(3)) >>> a, b, c (1,]]></description><link>http://direct.ecency.com/programming/@boyanpro/python-tricks-20-unpacking</link><guid isPermaLink="true">http://direct.ecency.com/programming/@boyanpro/python-tricks-20-unpacking</guid><category><![CDATA[programming]]></category><dc:creator><![CDATA[boyanpro]]></dc:creator><pubDate>Tue, 07 May 2019 06:38:24 GMT</pubDate></item><item><title><![CDATA[Python Tricks #19 - Oneliner to swap values between variables]]></title><description><![CDATA[>>> a=7 >>> b=5 >>> b, a =a, b >>> a 5 >>> b 7]]></description><link>http://direct.ecency.com/programming/@boyanpro/python-tricks-19-oneliner-to-swap-values-between-variables</link><guid isPermaLink="true">http://direct.ecency.com/programming/@boyanpro/python-tricks-19-oneliner-to-swap-values-between-variables</guid><category><![CDATA[programming]]></category><dc:creator><![CDATA[boyanpro]]></dc:creator><pubDate>Fri, 03 May 2019 10:25:12 GMT</pubDate></item><item><title><![CDATA[Python Tricks #18 - Store values of a list into new variables]]></title><description><![CDATA[>>> a = [1, 2, 3] >>> x, y, z = a >>> x 1 >>> y 2 >>> z 3]]></description><link>http://direct.ecency.com/programming/@boyanpro/python-tricks-18-store-values-of-a-list-into-new-variables</link><guid isPermaLink="true">http://direct.ecency.com/programming/@boyanpro/python-tricks-18-store-values-of-a-list-into-new-variables</guid><category><![CDATA[programming]]></category><dc:creator><![CDATA[boyanpro]]></dc:creator><pubDate>Fri, 03 May 2019 10:18:00 GMT</pubDate></item><item><title><![CDATA[Python Tricks #17 - Measure the execution time of small bits of Python code with the "timeit" module]]></title><description><![CDATA[# The "timeit" module lets you measure the execution # time of small bits of Python code >>> import timeit >>> timeit.timeit('"-".join(str(n) for n in range(100))',]]></description><link>http://direct.ecency.com/programming/@boyanpro/python-tricks-16-measure-the-execution-time-of-small-bits-of-python-code-with-the-timeit-module</link><guid isPermaLink="true">http://direct.ecency.com/programming/@boyanpro/python-tricks-16-measure-the-execution-time-of-small-bits-of-python-code-with-the-timeit-module</guid><category><![CDATA[programming]]></category><dc:creator><![CDATA[boyanpro]]></dc:creator><pubDate>Thu, 02 May 2019 08:26:33 GMT</pubDate></item><item><title><![CDATA[Python Tricks #16 - All or Any]]></title><description><![CDATA[x = [True, True, False] if any(x): print("At least one True") if all(x): print("Not one False") if any(x) and not all(x): print("At least one True and one False")]]></description><link>http://direct.ecency.com/programming/@boyanpro/python-tricks-16-all-or-any</link><guid isPermaLink="true">http://direct.ecency.com/programming/@boyanpro/python-tricks-16-all-or-any</guid><category><![CDATA[programming]]></category><dc:creator><![CDATA[boyanpro]]></dc:creator><pubDate>Wed, 01 May 2019 11:00:42 GMT</pubDate></item><item><title><![CDATA[Python Tricks #15 - Convert list of list into single list]]></title><description><![CDATA[# import the itertools import itertools # Declaring the list geek geek = [[1, 2], [3, 4], [5, 6]] # chain.from_iterable() function returns the elements of nested list # and iterate from first list of iterable]]></description><link>http://direct.ecency.com/programming/@boyanpro/python-tricks-15-convert-list-of-list-into-single-list</link><guid isPermaLink="true">http://direct.ecency.com/programming/@boyanpro/python-tricks-15-convert-list-of-list-into-single-list</guid><category><![CDATA[programming]]></category><dc:creator><![CDATA[boyanpro]]></dc:creator><pubDate>Wed, 01 May 2019 10:47:48 GMT</pubDate></item><item><title><![CDATA[Python Tricks #14 - Binary search is faster than linear]]></title><description><![CDATA[# Given list B = [2,5,7,8,9,11,14,16] find if 14 is present in this list or not. def binarySearch(ls,data): first = 0 last = len(ls)-1 while first<=last: mid = (first+last)//2 if ls[mid] == data: return]]></description><link>http://direct.ecency.com/programming/@boyanpro/python-tricks-14-binary-search-is-faster-than-linear</link><guid isPermaLink="true">http://direct.ecency.com/programming/@boyanpro/python-tricks-14-binary-search-is-faster-than-linear</guid><category><![CDATA[programming]]></category><dc:creator><![CDATA[boyanpro]]></dc:creator><pubDate>Tue, 30 Apr 2019 08:18:39 GMT</pubDate></item><item><title><![CDATA[Python Tricks #13 - Find The Most Frequent Value In A List]]></title><description><![CDATA[# Most frequent element in a list >>> a = [1, 2, 3, 1, 2, 3, 2, 2, 4, 5, 1] >>> print(max(set(a), key = a.count)) 2 # Using Counter from collections >>> from collections import]]></description><link>http://direct.ecency.com/programming/@boyanpro/python-tricks-13-find-the-most-frequent-value-in-a-list</link><guid isPermaLink="true">http://direct.ecency.com/programming/@boyanpro/python-tricks-13-find-the-most-frequent-value-in-a-list</guid><category><![CDATA[programming]]></category><dc:creator><![CDATA[boyanpro]]></dc:creator><pubDate>Mon, 29 Apr 2019 08:07:45 GMT</pubDate></item><item><title><![CDATA[Python Tricks #12 - Pretty print dictionaries]]></title><description><![CDATA[# The standard string repr for dicts is hard to read: >>> my_mapping = {'a': 23, 'b': 42, 'c': 0xc0ffee} >>> my_mapping {'b': 42, 'c': 12648430. 'a': 23} # 😞 # The "json" module]]></description><link>http://direct.ecency.com/programming/@boyanpro/python-tricks-12-pretty-print-dictionaries</link><guid isPermaLink="true">http://direct.ecency.com/programming/@boyanpro/python-tricks-12-pretty-print-dictionaries</guid><category><![CDATA[programming]]></category><dc:creator><![CDATA[boyanpro]]></dc:creator><pubDate>Mon, 29 Apr 2019 07:53:00 GMT</pubDate></item><item><title><![CDATA[Python Tricks #11 - Function argument unpacking]]></title><description><![CDATA[# Why Python Is Great: # Function argument unpacking def myfunc(x, y, z): print(x, y, z) tuple_vec = (1, 0, 1) dict_vec = {'x': 1, 'y': 0, 'z': 1} >>> myfunc(*tuple_vec) 1, 0, 1 >>>]]></description><link>http://direct.ecency.com/programming/@boyanpro/python-tricks-11-function-argument-unpacking</link><guid isPermaLink="true">http://direct.ecency.com/programming/@boyanpro/python-tricks-11-function-argument-unpacking</guid><category><![CDATA[programming]]></category><dc:creator><![CDATA[boyanpro]]></dc:creator><pubDate>Mon, 29 Apr 2019 07:47:33 GMT</pubDate></item><item><title><![CDATA[Python Tricks #10 - Printing a list]]></title><description><![CDATA[# Declaring the list geek >>> geek = ['Geeks', 'Programming', 'Algorithm', 'Article'] # Directly printing the list >>> print ("Simple List:", geek) Simple List: ['Geeks',]]></description><link>http://direct.ecency.com/programming/@boyanpro/python-tricks-10-printing-a-list</link><guid isPermaLink="true">http://direct.ecency.com/programming/@boyanpro/python-tricks-10-printing-a-list</guid><category><![CDATA[programming]]></category><dc:creator><![CDATA[boyanpro]]></dc:creator><pubDate>Fri, 26 Apr 2019 06:59:45 GMT</pubDate></item></channel></rss>