#python python... PYTHON 🔛 🚀
11 subscribers
914 photos
7 videos
158 files
1.54K links
Download Telegram
Различные способы одновременного тестирования нескольких флагов в Python

#codeexample

x, y, z = 0, 1, 0

if x == 1 or y == 1 or z == 1:
     print('passed')

if 1 in (x, y, z):
      print('passed')

# These only test for truthiness:
if x or y or z:
      print('passed')

if any((x, y, z)):
      print('passed')
#codeexample

Python 3.5+ позволяет передавать несколько наборов
аргументов ключевого слова («kwargs») для функции в пределах одного вызова, используя синтаксис «»:

def process_data(a, b, c, d):
print(a, b, c, d)
 x = {'a': 1, 'b': 2}
y = {'c': 3, 'd': 4}


process_data(**x, **y)
# 1 2 3 4


process_data(**x, c=23, d=42)
#1 2 23 42