[SAGA-RG] SAGA attributes as Python dictionaries?

Ole Weidner oweidner at cct.lsu.edu
Wed Nov 4 12:43:36 CST 2009


Hi,

slightly off-topic, but where can I actually download VU's Python  
bindings?

Cheers,
Ole

On Nov 4, 2009, at 9:48 AM, Mathijs den Burger wrote:

> Hi all,
>
> For the Python language bindings, we (at the VU) are thinking about
> CCT's idea to use the Python 'dict' interface for SAGA attributes.  
> While
> we like the idea to use Python-specific constructs in the language
> bindings, it seems that SAGA attributes differ in semantics from the
> 'associative arrays' that are Python's dictionaries.
>
> Some examples where Python dicts and SAGA attributes differ:
>
> 1. They throw different exceptions (e.g. KeyError vs BadParameter /
> PermissionDenied / DoesNotExist / AuthenticationFailed /
> AuthorizationFailed / BadParameter / IncorrectState / NoSuccess)
>
> 2. Removing SAGA attributes is permanent (AFAIK when talking to  
> Ceriel),
> while a deleted dict item can be re-added latter
>
> 3. Dictionaries accept any hashable object, whereas SAGA attributes  
> only
> accept a set of defined values.
>
> Exposing SAGA attributes as a dictionary may therefore lead to
> confusion, as the two are similar but not identical.
>
> Another option for easy access (which we use in our implementation on
> top of Java SAGA) is to use Python's 'property' construct for each
> defined attribute. This allows you to do, for example:
>
>>>> from saga import job
>>>> js = job.JobDescription()
>>>> js.Executable = "/bin/date"
>>>> js.Arguments = [ "-R" ]
>
> Python translates such property access to calling getter an setter
> functions that can do additional checking. Very flexible, and the  
> syntax
> is even shorter than using the 'dict' interface. Wouldn't that be a
> better option for easy access to SAGA attributes in Python?
>
> best,
> Mathijs
>
>
> --
>  saga-rg mailing list
>  saga-rg at ogf.org
>  http://www.ogf.org/mailman/listinfo/saga-rg



More information about the saga-rg mailing list