Using 'append()' in Pipeline Block Editor does not work?

this is a weird one. i copy/pasted some working code into the PBE (Pipeline Block Editor). it fails. here's the code:

assetList = []
for item in py_userDataset:
  assetList.append(item['assetName'])
return assetList

this tanks out: assetList is empty. whut? so on a wild guess, i tried this instead:

assetList = ''
for item in py_userDataset:
  assetList = assetList + item['assetName'] + ','
return assetList

this actually returns a comma-delimited string of ALL the assets. BUT now a NEW problem presents itself: split() doesn't work:

correctedList = assetList.split(',')

so why are these methods not working in the PBE? they work everywhere else!

Out of curiosity, what happens if you try this instead?

return [item['assetName'] for item in py_userDataset]

What does the rest of the code look like? Did you change it between example 1 and example 2?

the only thing that changes is what i've shown. everything works up to the point of using either the append() or the split(). so the py_userDataset is correctly generated; it populates the string concatenation just fine (all 200 items).

ultimately, what i need, given that i'm building a custom roster, is to wind up with a list of a dict of a list (:roll_eyes:) that looks like this:

[{'email': ['blort@bink.ca', 'snort@donk.co.uk']}]

everything works until the append() or the split(). it's just ridiculous. for example:

for item in py_userData:
  assetList = assetList + item['assetName'] + ','  #<-- builds fine
  otherAssetList.append(item['assetName'])  #<-- does not compute

the output, from above, of assetList is a big string: 'blort@bink.ca,snort@donk.co.uk,(+198 more)' which is what you expect. but there is NOTHING in otherAssetList. it just doesn't build. and they are writing the same data! :exploding_head:

and just to re-emphasize: this is ONLY in the PBE. it works JUST FINE everywhere else.

So, JSON.

My thought is that even though you’re assuming the object you’re working with is just a standard python list, it can be and probably is something different depending on the context. However, it does have a string representation so the concatenation works.

okay. i am so :angry: at this. i got on a call with Support. 2 hours. wasn't working. tech stymied. we started adding log statements to see why append() and split() weren't working. halfway through, having ONLY added log statements, script start working. no joke, no lie. tech was like: "huh, it's working now."

this isn't the first time this kind of thing has happened, either. tech is calling back in the morning to re-run through the project with me to find out what the hell happened. i'm absolutely banjaxxed. :exploding_head:

i think our Ignition install is haunted... :ghost: :jack_o_lantern: :skull: