The gdict container
Keywords: gildas-python

Next: The Sic object in Up: Using SIC from Python Previous: Special commands Contents Index

###
The `gdict` container

Modules have a special attribute named `gdict` (actually, a class instance) from which all Gildas variables can be easily retrieved and defined:

    >>> import pysic
    >>> pysic.get()
    Importing all SIC variables into Python...
    ... done.
    >>> g = pysic.gdict
    >>> g
    Container for imported Gildas variables. Variables are accessed as
       attributes of this object.
    >>> dir(g)         # List of all imported variables
    ['__builtins__', 'debug_recursive', 'gildas_node', 'linedb', 'no', 'pi',
    'run_window', 'sic', 'type_dble', 'type_inte', 'type_logi', 'type_long',
    'type_real', 'yes']
    >>> g.pi           # Get Gildas variable PI
    3.14159265359
    >>> g.a = (1,2,3)  # Set a new Gildas variable A
    A               is a      INTEGER*4, 1D (3x0x0x0)   (GLOBAL,RW) -> a
    >>> pysic.comm('exa a')
    A               is an integer Array      of dimensions      3
                1            2            3

Whatever the name area has been defined by user with `setgdict`, any `gdict` instance will allways find the Gildas dictionary8. The variable handling can be found easier than the dictionary equivalent `d['pi']`.