title: Normal 'def' function instead of lambda
body: <p>The following code produces a web map with countries colored by population which values come from world.json. </p>
  
  <pre><code>import folium
  
  map=folium.Map(location=[30,30],tiles='Stamen Terrain')
  
  map.add_child(folium.GeoJson(data=open('world.json', encoding='utf-8-sig'),
  name="Unemployment",
  style_function=lambda x: {'fillColor':'green' if x['properties']['POP2005'] &lt;= 10000000 else 'orange' if 10000000 &lt; x['properties']['POP2005'] &lt; 20000000 else 'red'}))
  
  map.save('file.html')
  </code></pre>
  
  <p>Link of <a href="https://www.dropbox.com/s/hztkqnpnh1u5nag/world.json?dl=0" rel="nofollow noreferrer">world.json</a>.</p>
  
  <p>I was wondering if it's possible to use a normal function created with <code>def</code> instead of a lambda function as the value of the <code>style_function</code> argument. I tried creating a function for that:</p>
  
  <pre><code>def feature(x):
      file = open("world.json", encoding='utf-8-sig')
      data = json.load(file)
      population = data['features'][x]['properties']['POP2005']
      d ={'fillColor':'green' if x['properties']['POP2005'] &lt;= 10000000 else 'orange' if 10000000 &lt; x['properties']['POP2005'] &lt; 20000000 else 'red'}
      return d
  </code></pre>
  
  <p>However, I can't think of how to use it in <code>style_function</code>. Is this possible or is the lambda function irreplaceable here?</p>