from django.db.models.signals import post_save
from django.dispatch import receiver
# method for updating
@receiver(post_save, sender=Zakaz)
def update_stock(sender, instance, **kwargs):
# instance - созданный объект, к которому можно обратится
# Здесь создавать объект
from aiogram import BaseMiddleware
from aiogram.types import Message
class CounterMiddleware(BaseMiddleware):
def __init__(self) -> None:
self.counter = 0
async def __call__(
self,
handler: Callable[[Message, Dict[str, Any]], Awaitable[Any]],
event: Message,
data: Dict[str, Any]
) -> Any:
self.counter += 1
data['counter'] = self.counter
return await handler(event, data)
import asyncio
import discord
from discord.ext import commands
from discord.ext.tasks import loop
bot = commands.Bot(command_prefix = '!!')
@loop(seconds=1)
async def bg_task():
pass # doing smth
@bot.command()
async def hi(ctx):
await ctx.send('Hi!')
bg_task.start()
bot.run('************************')
Choose.objects.get_or_create(voter=request.user)
import time
def main() -> None:
a = 1
b = 2
c = 3
d = 4
e = 5
some_string = f'{a} {b} {c} {d} {e}'
print(some_string)
if __name__ == '__main__':
main()
time.sleep(10)
def main_2() -> None:
a = 1
b = 2
c = 3
d = 4
e = 5
some_string = f'{a} {b} {c} {d} {e}'
print(a, b, c, d, e)
import time
from os import system, name
def main():
sec = 0
minutes = 0
hour = 0
while True:
hour_high = hour//10
hour_low = hour%10
min_high = minutes//10
min_low = minutes%10
sec_high = sec//10
sec_low = sec%10
timestring = f'{hour_high}{hour_low}:{min_high}{min_low}:{sec_high}{sec_low}'
system('cls')
print(timestring)
sec+=1
time.sleep(1)
if sec == 60:
minutes+=1
sec = 0
if minutes == 60:
hour+=1
minutes = 0
if __name__ == '__main__':
main()