Uploaded image for project: 'Request For Comments'
  1. Request For Comments
  2. RFC-596

Add getitem to PropertySet and PropertyList

    Details

    • Type: RFC
    • Status: Implemented
    • Resolution: Done
    • Component/s: DM
    • Labels:
      None

      Description

      In RFC-434 we deprecated PropertySet.get() and replaced it with getScalar and getArray. Whilst this seems safer for many users, it means that a PropertySet can't ever behave like a Python dict. This is a real annoyance with astro_metadata_translator since that accepts any dict-like headers (including those from Astropy) and I have to have special workarounds all over it to convert PropertyList to dict.

      Can I please add PropertySet.__getitem__ which behaves like get() and allows me to say ps["KEY"]? (there is a __setitem__ already for assignment using normal dict syntax). The toDict and toOrderedDict methods already use the Pythonic approach of returning a list or scalar depending on the contents of the PropertyList.

      Ideally I'd like to add back a get() that looks like a dict get and allows defaulting, but I imagine that is a harder sell.

      This __getitem__ proposal is adding to the API and not changing any existing API.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                tjenness Tim Jenness
                Reporter:
                tjenness Tim Jenness
                Watchers:
                Jim Bosch, John Parejko, John Swinbank, Kian-Tat Lim, Krzysztof Findeisen, Robert Lupton, Russell Owen, Tim Jenness
              • Votes:
                1 Vote for this issue
                Watchers:
                8 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Planned End:

                  Summary Panel