I want to convert python boolean to a JS boolean literal. This is what I work with:
store = dict(vat=True) if store['vat']: store.update({'vat': 'true'}) else: store.update({'vat': 'false'})
Is there a more or less correct way to replace this piece of code?
>>> store['vat'] = json.dumps(store['vat']) >>> store {'vat': 'true'}
In JS, a positive integer value is truly true, and 0 (zero) is false.
You can try passing 0 as JS false and 1 as JS true (do not use negative values)
>1 == true true >0 == true false >0 == false true >1 == false false