Login
Discover
Waves
Decks
Plus
Login
Signup
Topics
New
Trending
Hot
New
New
Trending
Hot
New
Payouts
Muted
Promoted
Global
Top communities
Create decentralized community
latest #pytricks created topics on internet
boyanpro
programming
2019-05-22 16:07
Python Tricks #29 - Python's built-in HTTP server
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
$ 0.041
10
1
boyanpro
programming
2019-05-19 13:23
Python Tricks #28 - Use dicts as switch/case
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
$ 0.132
6
boyanpro
programming
2019-05-15 06:41
Python Tricks #27 - f-strings Python3.6+
# 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
$ 2.301
9
4
boyanpro
programming
2019-05-14 22:06
Python Tricks #26 - Your Dict Size
# 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
$ 0.020
5
awesomegames007
Hive Gaming
2026-04-15 16:45
Promoted
Chivalry 2 - Gotta firmly grasp the highlander!
Kelk tells me a story about a guy that would dress up as lu bu and MASSACRE PEOPLE! I got some great kills, I highlight the better ones with some slooowmooo. Some of them thought they could get away from
$ 1.308
158
boyanpro
programming
2019-05-13 08:08
Python Tricks #25 - Functions Superiority
# 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.
$ 0.023
4
1
boyanpro
programming
2019-05-10 05:57
Python Tricks #24 - Taking a string input
# 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)
$ 1.470
49
boyanpro
programming
2019-05-08 07:02
Python Tricks #23 - is vs ==
# "is" vs "==" >>> a = [1, 2, 3] >>> b = a >>> a is b True >>> a == b True >>> c = list(a) >>> a == c True >>> a is c
$ 0.180
7
boyanpro
programming
2019-05-08 06:46
Python Tricks #22 - Dict Tricks
# 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,
$ 0.167
7
shandalar
hive
2026-04-18 11:28
Promoted
Web3 wealth building on HIVE
HIVE got a new Dolphin this year, becouse...
$ 1.369
79
6
boyanpro
programming
2019-05-07 06:49
Python Tricks #21 - Manipulating Lists
# 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] >>>
$ 1.487
123
boyanpro
programming
2019-05-07 06:38
Python Tricks #20 - Unpacking
>>> 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,
$ 0.367
52
boyanpro
programming
2019-05-03 10:25
Python Tricks #19 - Oneliner to swap values between variables
>>> a=7 >>> b=5 >>> b, a =a, b >>> a 5 >>> b 7
$ 0.035
5
1
boyanpro
programming
2019-05-03 10:18
Python Tricks #18 - Store values of a list into new variables
>>> a = [1, 2, 3] >>> x, y, z = a >>> x 1 >>> y 2 >>> z 3
$ 0.038
8
sacra97
Movies & TV Shows
2026-04-17 18:07
Promoted
🎬 Sherlock & Daughter (2025) / serie review [ES/EN]
Fuente/Source filmaffinity No he visto nada en las semanas pasadas que me llamara la atención. Pero ayer mi hijo me coloco esta serie y aunque el personaje Sherlock Holmes lo conocemos en diferentes historias
$ 4.257
485
10
boyanpro
programming
2019-05-02 08:26
Python Tricks #17 - Measure the execution time of small bits of Python code with the "timeit" module
# 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))',
$ 0.167
12
7
boyanpro
programming
2019-05-01 11:00
Python Tricks #16 - All or Any
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")
$ 0.033
9
boyanpro
programming
2019-05-01 10:47
Python Tricks #15 - Convert list of list into single list
# 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
$ 0.140
8
boyanpro
programming
2019-04-30 08:18
Python Tricks #14 - Binary search is faster than linear
# 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
$ 1.335
363
2
gungunkrishu
Olio di Balena
2026-04-16 11:49
Promoted
Discipline, Leadership & Success: My Daughter’s DISHI GUPTA - Inspiring CBSE 10th Journey...
Hey All, Finally, the wait is over for the students who appeared for the CBSE [Central Board of Secondary Education] Class X board exams. Just as an FYI, my daughter DISHI GUPTA also appeared for the exams.
$ 15.472
345
9
boyanpro
programming
2019-04-29 08:07
Python Tricks #13 - Find The Most Frequent Value In A List
# 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
$ 1.336
6
boyanpro
programming
2019-04-29 07:53
Python Tricks #12 - Pretty print dictionaries
# 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
$ 0.717
74
boyanpro
programming
2019-04-29 07:47
Python Tricks #11 - Function argument unpacking
# 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 >>>
$ 0.322
9
boyanpro
programming
2019-04-26 06:59
Python Tricks #10 - Printing a list
# Declaring the list geek >>> geek = ['Geeks', 'Programming', 'Algorithm', 'Article'] # Directly printing the list >>> print ("Simple List:", geek) Simple List: ['Geeks',
$ 0.292
88