You could use a ternary operator if you like those though it might be very wordy and I am not sure it actually makes it cleaner.
tag_path = ‘{tag_path}/{name}’.format(tag_path=json.get(‘tagPath’), name=json.get(‘name’) if json.get(‘tagPath’) else json.get('name')
Is your else clause correct? You define tag_path but then don’t use it. How do they get combined at the end? Feels like you could probably do your tag_path and base_path in ternary operators but again - I don’t think that always makes code cleaner or more readable.
Only other thing I would say - pick one, snake_case or camelCase, it looks like you use both.
Also, I prefer camelCase in jython, because it is the Java standard and because snake_case makes my eye twitch. It doesn't really matter, but it helps with continuity when you're using Java classes, plus that is the standard that IA uses with their scripting functions.
Thx for you answer, it actually helped me decide on how to do it!
About the different types, we use snake_case, but I have to use camelCase because I'm working with tags, and the tags use camelCase. So all my code is snake_case except for the values on the dictionary that are meant to work with tags.
Throwing my hat in the ring (this does something slightly different to your initial sample, in that it always appends name to the path, but that seems likely to be what you want anyways):