This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
import importlib | |
import asyncio | |
import binascii | |
from bitstring import BitArray, ConstBitStream | |
import protocol | |
import random | |
import html | |
import time | |
from time import mktime |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
import importlib | |
import asyncio | |
import binascii | |
from bitstring import BitArray, ConstBitStream | |
import protocol | |
import random | |
import html | |
import time | |
from time import mktime |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Привет, есть 3 модельки, как сформировать запрос чтобы выбести все LocationCompany с определеном city или sector, + DomainService domain + Service service_type, name | |
class Service(models.Model): | |
name = models.CharField(max_length=20, blank=True, null=True) | |
service_type = models.ForeignKey(Service_type, on_delete=models.CASCADE) | |
price = models.DecimalField(max_digits=10, decimal_places=0) | |
slug = models.SlugField(max_length=30) | |
class DomainService(models.Model): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
a = int(input()) | |
b = int(input()) | |
c = int(input()) | |
d = int(input()) | |
if a == c - 1 or a == c + 1 or a == c: | |
print("YES") | |
elif b == d - 1 or b == d + 1 or b == d: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
In [14]: class LazyInit(type): | |
...: def __new__(mcs, name, bases, namespace): | |
...: namespace["__init__"] = lambda self, *args, **kwargs: vars(self).update(kwargs) | |
...: return super().__new__(mcs, name, bases, namespace) | |
...: | |
In [15]: class Foo(metaclass=LazyInit): | |
...: def __init__(self, name): | |
...: pass | |
...: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
In [1]: class LazyInit: | |
...: def __new__(cls, **kwargs): | |
...: instance = super().__new__(cls) | |
...: for t in instance.__init__.__code__.co_varnames[1:]: | |
...: setattr(instance, t, kwargs[t]) | |
...: return instance | |
...: | |
In [2]: class Foo(LazyInit): | |
...: def __init__(self, name): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from http.server import BaseHTTPRequestHandler, HTTPServer | |
import time, ssl | |
hostName = "localhost" | |
hostPort = 9000 | |
class MyServer(BaseHTTPRequestHandler): | |
def do_GET(self): | |
self.send_response(200) | |
self.send_header("Content-type", "text/html") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
# импортируем библиотеки | |
import sys | |
from PySide2 import QtWidgets | |
from PySide2.QtCore import (QCoreApplication, QMetaObject, QRect) | |
from PySide2.QtWidgets import * | |
from telethon import TelegramClient, events | |
from pars_conf import account, list_all, key_words # импортируем данные из файл конфигурации |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def save_all(*values: Any) -> List[Any]: | |
res = [] # not all cases have hashable objects | |
for i in values: | |
if i is not None and i not in res: | |
res.append(i) | |
return res | |
def submerge(*values: Any) -> List[Any]: | |
res = [] | |
for value in values: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import unittest | |
import panel as p | |
class AngleTestCase(unittest.TestCase): | |
def setUp(self): | |
self.ang = p.Angle() | |
def test_get_angle_type(self): | |
self.assertEqual(self.ang.angle_type, 0) |