Python_Labs🐍
587 subscribers
267 photos
11 videos
28 files
204 links
加入频道
The get() method on Python dicts and its "default" arg

#pytrick
Python's namedtuples can be a great alternative to defining a class manually
#pytrick
You can use "json.dumps()" to pretty-print Python dicts
... (as an alternative to the "pprint" module)
#pytrick
"is" vs "=="
#pytrick
functools — Higher-order functions and operations on callable objects

partial gives default values to the parameters of a function that would otherwise not have default values.
#pytrick
Functions are first-class citizens in Python
#pytrick
Dicts can be used to emulate switch/case statements

#pytrick
Python's list comprehensions are awesome

even_squares = [x * x for x in range(10) if not x % 2]

#pytrick
Python 3.5+ type annotations
#pytrick
روشی که برای تولید تمام حالت ها در brute-force پسوردها هم استفاده میشود!

itertools.permutations() generates permutations for an iterable.

#pytrick
Peeking Behind The Bytecode Curtain

#pytrick #bytecode
Lambda Functions

(lambda x, y: x + y)(5, 3)

#pytrick
@classmethod vs @staticmethod vs "plain" methods (part 2)

#pytrick