Skip to main content
Archived

fmeobjects support for complex lists

  • December 23, 2015
  • 4 replies
  • 60 views

david_r
Celebrity

It would be helpful if the fmeobjects API had better support for complex lists. Consider the list:

_list{0}.id = '502' _list{0}.text = 'abc' _list{1}.id = '36' _list{1}.text = 'xyz'

The following fmeobjects method currently returns None:

items = feature.getAttribute('_list{}') 

To access child elements, you currently have to access them invidudually and then assemble them into an appropriate structure yourself.

It would be very handy if the getAttribute() method could return a nested Python dictionary containing the entire list with its elements, e.g. using the sample list above:

items = {0: {'id': '502', 'text': 'abc'}, 1: {'id': '36', 'text': 'xyz'}}

This would get rid of a lot of boilerplate code in Python scripts dealing with FME lists, as we could access individual list items using syntax like:

>>> print items[1]['text'] 'xyz'
This post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

4 replies

takashi
Celebrity
  • December 23, 2015

That's a nice idea. It might also be good that the return value is a list containing dictionaries as its elements, similar to a JSON array. e.g.

>>> print items [{'id': '502', 'text': 'abc'}, {'id': '36', 'text': 'xyz'}] >>> print items[0]['id'] 502

david_r
Celebrity
  • Author
  • December 23, 2015

Agree. That would of course also be perfectly fine.


david_r
Celebrity
  • Author
  • June 14, 2016

dbaldacchino1
Enthusiast
Forum|alt.badge.img+14

I'm just starting to use some python for complex list handling and am finding it's not possible to write attributes with nested lists. So I think this wish is related to what I'm butting my head against (ex: setting attribute to [['A1', 'A2'],['B1','B2'],....])