Skip to content

Instantly share code, notes, and snippets.

@Fhernd
Created September 29, 2018 13:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Fhernd/90321d967614950fe5f47ed02025d538 to your computer and use it in GitHub Desktop.
Save Fhernd/90321d967614950fe5f47ed02025d538 to your computer and use it in GitHub Desktop.
Conversión de clase a función. OrtizOL.
from urllib.request import urlopen
def plantilla_url(plantilla):
def abrir(**kwargs):
return urlopen(plantilla.format_map(kwargs))
return abrir
clima = plantilla_url('https://samples.openweathermap.org/data/2.5/forecast?id={id}&appid=b1b15e88fa797225412429c1c50c122a1')
for linea in clima(id='524901', appid='b1b15e88fa797225412429c1c50c122a1'):
print(linea.decode('utf-8'))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment