How To Replace Repeated Loops With Higher Order Functions In Python

1. NOTES

  • Have a top-level parser that goes to the line item of a config file
  • Have a particular query/command that fixes that

2. EXAMPLE

  • I am not parsing a long config file, but a long manifest table listing documents in the knowledge base with the following structure which looks like

2.1. REPEATED LOOP

  • To get a single attribute within the app I need to have an elaborate loop and I need to repeat the looping each time to get down to the article level

3. SOLUTION

3.1. HIGHER ORDER FUNCTION

3.2. PARTICULAR FUNCTION — QUERY

3.3. CALL

3.4. PARTICULAR FUNCTION — COMMAND

3.5. CALL

  • Once the pattern is established, it is pretty much the same thing

4. LINKS

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Pavol Kutaj

Pavol Kutaj

Infrastructure Support Engineer/Technical Writer (Snowplow Analytics) with a passion for Python/writing documentation. More about me: https://pavol.kutaj.com