Skip to content

Instantly share code, notes, and snippets.

@homelinen
Created May 19, 2015 12:39
Show Gist options
  • Save homelinen/757a83ee0540c121665e to your computer and use it in GitHub Desktop.
Save homelinen/757a83ee0540c121665e to your computer and use it in GitHub Desktop.
> + for child in config.children:
> + if child.key == "TypesDB":
> + paths = child.value
I think there's probably a more Pythonic way to do this.
List comprehensions is one
paths = [ child.value for child in config.children if child.key == "TypeDB" ]
Using filter to filter out the children and then doing a list comprehension is more readable than above but requries two O(n) loops.
What is written works, and I think there's a better way than my two suggestions. Feel free to ignore.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment