Заметки Питониста
14.8K subscribers
3.35K photos
17 videos
1.79K links
Все что связано с Python, уже в наших заметках.

Ссылка: @Portal_v_IT

Сотрудничество: @oleginc
Download Telegram
def f(x, y, z):
return x + y + z

d1 = {'x': 1, 'y': 2}
d2 = {'y': 3, 'z': 4}

try:
print(f(**d1, **d2))
except TypeError:
print("TypeError")


💕 Наш уютный чатик

#Python
Please open Telegram to view this post
VIEW IN TELEGRAM
class A:
def __new__(cls):
return 42

def __init__(self):
print("Init")

print(A())


💕 Наш уютный чатик

#Python
Please open Telegram to view this post
VIEW IN TELEGRAM
d = {'a': 1, 'b': 2, 'c': 3}
try:
for k in d:
del d[k]
print(len(d))
except RuntimeError:
print("RuntimeError")


💕 Наш уютный чатик

#Python
Please open Telegram to view this post
VIEW IN TELEGRAM
x = [0, 1]
i = 0
i, x[i] = 1, 2
print(x)


💕 Наш уютный чатик

#Python
Please open Telegram to view this post
VIEW IN TELEGRAM
def f(x, y, z):
return x + y + z

d1 = {'x': 1, 'y': 2}
d2 = {'y': 3, 'z': 4}

try:
print(f(**d1, **d2))
except TypeError:
print("TypeError")


💕 Наш уютный чатик

#Python
Please open Telegram to view this post
VIEW IN TELEGRAM
print((1, 2) < (1, 2, -1))


💕 Наш уютный чатик

#Python
Please open Telegram to view this post
VIEW IN TELEGRAM
def modify(x, y=[]):
y.append(x)
return sum(y)

result = modify(5) + modify(7) + modify(4)
print(result)


💕 Наш уютный чатик

#Python
Please open Telegram to view this post
VIEW IN TELEGRAM
class A:
def __new__(cls):
return 42

def __init__(self):
print("Init")

print(A())


💕 Наш уютный чатик

#Python
Please open Telegram to view this post
VIEW IN TELEGRAM
class A:
def __init__(self):
self.__x = 1

def get_x(self):
return self.__x

class B(A):
def __init__(self):
super().__init__()
self.__x = 2

b = B()
print(b.get_x())


💕 Наш уютный чатик

#Python
Please open Telegram to view this post
VIEW IN TELEGRAM
lst = [x for x in range(10) if x % 2 == 0 if x % 3 == 0]
print(lst)


💕 Наш уютный чатик

#Python
Please open Telegram to view this post
VIEW IN TELEGRAM