Using saved database settings to generate code (if-statements) [closed]

  case-statement, django, if-statement, python

I currently have an app that generates financial documents based on user-set settings

These settings look something like this:

Trial Balance

☐ Use main accounts

☐ Include Opening Balances

☐ Print Null Values

☐ Print Account Number

All these settings are boolean variables and can easily be checked with if UseMainAccount == True :

However, this would obviously take quite a few if statements to complete and can become very tedious.

Is there a way to shorten this process (I know in Delphi and some other codes there are "case" statements for this. But would a case statement be possible in Django/Python

Source: Python Questions

LEAVE A COMMENT