Python Dictionaries

From Federation of Earth Science Information Partners
Jump to: navigation, search

< Back to Glossary | Edit with Form

Python_Dictionaries Description: Python is a simple programming language. It contains the dictionary datatype, which is a simple key=value hierarchical database. Due to simple syntax, the datafed WCS uses it as a configuration file, instead of xml files or something similar.

Contents

Glossary Domain: WCS

Related Links

Links to this page
No Links

Contributors

No Contributors

History

No History Available

Term Details


This is a dictionary:

   {'name':'NASA', 'version': '1.1.0' }

If there are multiple possible values for a key, list can be used.

   {'name':'NASA', 'accepted_versions': ['1.1.0', '1.1.1', '1.1.2'] }

This is a typical nested dictionary:

   VIEWS_location_info = {
       'location':{
           'service':'WFS',
           'version':'1.0.0',
           'table_alias':'Site',
           'columns':{
               'loc_code':{'column_alias':'SiteCode'},
               'lat':{'column_alias':'Latitude'},
               'lon':{'column_alias':'Longitude'},
               }
           },
       }

The variable VIEWS_location_info now refers to the dictionary and can be used elsewhere.

Because the dictionaries are just python objects, they don't have to be hand edited. They can be generated programmatically. This works:

   VIEWS_location_info = read_location_configuration()

This would call the function read_location_configuration when loading the configuration file.

Personal tools
Namespaces

Variants
Actions
Navigation
Toolbox