I am trying to understand this code from someone else's project. If you want the context itsit's here: https://github.com/newsapps/beeswithmachineguns/blob/master/beeswithmachineguns/bees.py#L501
IS_PY2IS_PY2 is just a boolean variable, trueTrue if the pythonPython major version is 2.
I know that a non-empty string is TrueTrue, but for some reason I don't understand openmodeopenmode is assigned either w'w' or wt'wt' rather than TrueTrue or FalseFalse.
openmode = IS_PY2 and 'w' or 'wt'
openkwargs = IS_PY2 and {} or {'encoding': 'utf-8', 'newline': ''}
Could someone explain the result?