Windows
- 1 ответ
- 0 вопросов
1
Вклад в тег
import time
def timer(f):
def subfunc(*args, **kwargs):
t = time.time()
res = f(*args, **kwargs)
res_3 = (time.time() - t)
mylist = [args[0].__name__, args[1], res_3]
print(mylist)
return res
return subfunc
@timer
def myfunc(expression, i=1000, sleep=2, args=[]):
time.sleep(sleep)
res_1 = expression(j for j in range(1, 10001))
res_2 = res_1 * i
return res_2
myfunc(sum, 20000)
myfunc(min, 20000)
def get_path_file(instance, filename):
category = instance.category.name
name = instance.name
return os.path.join('products_images', category, name[:25], filename)
cover = models.ImageField(upload_to=get_path_file, null=False)