def post_list(request):
return render(request, 'photo.html', {'last_photo': UploadFile.objects.last()})
<img src="{{ last_photo.image.url }}">
на элементарное казалось бы задание у меня уходит 2-3 часа
Так вот может есть какой то фундамент который нужен?
2 0 LOAD_FAST 0 (a)
2 LOAD_FAST 1 (b)
4 BINARY_ADD <-- Сложение a и b
6 RETURN_VALUE <-- Возврат результата
2 0 LOAD_CONST 1 (<code object do_it at 0x0000000004E59F60)
2 LOAD_CONST 2 ('<globals>.do_it')
4 MAKE_FUNCTION 0
6 STORE_FAST 0 (do_it)
4 8 LOAD_FAST 0 (do_it)
10 LOAD_CONST 3 (2)
12 LOAD_CONST 3 (2)
14 CALL_FUNCTION 2 <-- Вызов do_it
16 STORE_FAST 1 (x) <-- Присваивание x значения 4
5 18 LOAD_GLOBAL 0 (print)
20 LOAD_FAST 1 (x)
22 CALL_FUNCTION 1 <-- Вызов print
do_it
вызывается, а потом возвращённое из неё значение присваивается переменной x
from abc import ABC
import sys
from threading import Thread
from multiprocessing import Process
class Executor(ABC):
@abstractmethod
def execute(self, f):
pass
class ThreadExecutor(Executor):
def execute(self, f):
Thread(target=f).start()
class ProcessExecutor(Executor):
def execute(self, f):
Process(target=f).start()
def func():
print('Hello')
if __name__ == '__main___':
executor = None
if sys.argv[1] == 'thread':
executor = ThreadExecutor()
elif sys.argv[1] == 'process':
executor = ProcessExecutor()
else:
print('Usage:\n\t{} <thread|process>\n'.format(sys.argv[0]), file=sys.stderr)
sys.exit(1)
executor.execute(func)