animals = ['кот', 'собака', 'птица', 'рыба']
animals.pop(1)
animals.insert(2, 'хомяк')
print(animals[-2])
#Python
Please open Telegram to view this post
VIEW IN TELEGRAM
Please open Telegram to view this post
VIEW IN TELEGRAM
class Context:
def __enter__(self):
return "A"
def __exit__(self, *args):
return True
with Context() as c:
raise ValueError()
print(c)
#Python
Please open Telegram to view this post
VIEW IN TELEGRAM
def make_counter():
count = 0
def increment():
nonlocal count
count += 1
return count
return increment
c1 = make_counter()
c2 = make_counter()
c1()
print(c1(), c2())
#Python
Please open Telegram to view this post
VIEW IN TELEGRAM
Please open Telegram to view this post
VIEW IN TELEGRAM
Please open Telegram to view this post
VIEW IN TELEGRAM
Please open Telegram to view this post
VIEW IN TELEGRAM
Please open Telegram to view this post
VIEW IN TELEGRAM
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
😱1