Difference between revisions of "TruxtonOptions"

From truxwiki.com
Jump to navigation Jump to search
(Created page with "This class gives you access to configuration variables. =Methods= ==<code>getbool(name)</code>== This will retrieve a boolean setting from Truxton...")
 
Line 13: Line 13:
  
 
=Sample=
 
=Sample=
 
+
<source lang="Python" highlight="4,6-8">
<syntaxhighlight lang="Python" highlight="4,6-8">
 
 
import truxton
 
import truxton
  
Line 26: Line 25:
 
if __name__ == "__main__":
 
if __name__ == "__main__":
 
   main()
 
   main()
</syntaxhighlight>
+
</source>

Revision as of 11:24, 6 February 2021

This class gives you access to configuration variables.

Methods

getbool(name)

This will retrieve a boolean setting from Truxton based on its name.

getinteger(name)

This will retrieve an integer setting from Truxton based on its name.

getstring(name)

This will retrieve a string setting from Truxton based on its name.

Sample

import truxton

def main():
  options = truxton.options()

  print( "CreateTheDatabase: " + str(options.getbool("CreateTheDatabase")))
  print( "dbport: " + str(options.getinteger("dbport")))
  print( "dbname: " + str(options.getstring("dbname")))

if __name__ == "__main__":
  main()