I'm wondering about / in python.
I know that it divides two integers, but I've seen something like this
'NAME': BASE_DIR / 'db.sqlite3'
I'm wondering about / in python.
I know that it divides two integers, but I've seen something like this
'NAME': BASE_DIR / 'db.sqlite3'
Python allows defining the behaviour of operators when applied to custom classes using specially named methods ("dunders", from "double-underline"), as described here. The / operator's behaviour can be defined by .__truediv__(self, other) method. It is almost certainly the case here that BASE_DIR is an instance of pathlib.Path, which defines / as semantically equivalent to os.path.join for strings. You can read more here.
BASE_DIR is pathlib.Path object which supports the / operator for joining paths. You need to either use / or use os.path.join if you use strings.