add python api to set flags

Clean up unwanted changes caused by IDE extension -.-

Reworked implementation