sanic-session icon indicating copy to clipboard operation
sanic-session copied to clipboard

Why does this piece of code work?

Open simon-lund opened this issue 2 years ago • 2 comments

https://github.com/ahopkins/sanic-session/blob/551de4b503ab1a595b3b2b07cbe08806508a043e/sanic_session/base.py#L164-L169

Hello,

I was reading your code and stumbled upon the linked code lines.

There I don't understand why line 167 doesn't throw an error. Because if if not req[self.session_name] evaluates to True how can there be a modified field?

Best Simon

simon-lund avatar Dec 29 '22 14:12 simon-lund

It checks the value of req[self.session_name]'s modified field. learn python...

Zerogoki00 avatar Feb 01 '24 14:02 Zerogoki00

No reason to be toxic. I know Python very well.

I just don't make sense to me to access req[self.session_name].modified when not req[self.session_name] == True.

simon-lund avatar Feb 01 '24 19:02 simon-lund