I am learning to build a product cart app for an online shop. But while I was reading other's app, I found something I couldn't understand.
settings.py>
CART_ID = 'cart_in_session'
cart.py>
from decimal import Decimal
from django.conf import settings
from shop.models import Product
from coupon.models import Coupon
class Kart(object):
def __init__(self, request):
self.session = request.session
kart = self.session.get(settings.CART_ID)
if not kart:
kart = self.session[settings.CART_ID] = {}
self.kart = kart
I couldn't get this part of code snippet: if not kart: kart = self.session[settings.CART_ID] = {}
It has two "=" symbol and I am wondering if it's for assignment and if it's really an assignment, then why it sets CART_ID's value ("cart_in_session" for its matched key CART_ID) to {}