[SciPy-dev] alternate .flags interface

Fernando Perez Fernando.Perez at colorado.edu
Mon Oct 31 08:34:23 CST 2005


Perry Greenfield wrote:
> I'm wondering if the current flags interface couldn't be made a bit 
> easier to use to allow mapping of dictionary keys in to attributes. For 
> example:
> 
> instead of arr.flags["CONTIGUOUS"]
> 
> arr.flags.contiguous
> 
> If using a dictionary is considered useful (e.g., for getting the whole 
> state, it is still possible to allow arr.flags to return a dictionary 
> derived object that can be used wherever dictionaries are accepted, and 
> likewise, assigning to arr.flags should be able to take a dictionary of 
> flags. Any reason we can't support this interface?

Mmh.  What happens when you say

arr.flags.update = 1

and then pass arr.flags to a dict-expecting method which calls

arr.flags.update(otherdict)

?

I do like the idea of named attribute access, but the issue of name conflicts 
with the existing dict API needs to be dealt with first.  Either certain 
attribute names are disallowed (case in which you can just steal 
IPython.Struct for the implementation, which already does all of this), or 
some other policy must be devised.

Regards,

f




More information about the Scipy-dev mailing list