diff --git a/example_deco_LMO.py b/example_deco_LMO.py new file mode 100644 index 0000000..5dd0f44 --- /dev/null +++ b/example_deco_LMO.py @@ -0,0 +1,87 @@ + +def deco(func): + def inner(*args): + print("running inner") + return func(*args) + return inner + + +@deco +def target(): + print("running target") + +target() +print("pointeur de fonction target() :", target) +print("L'appel de target est remplacé par inner()") + + +registry = [] + +def register(func): + print("running register {}".format(func)) + registry.append(func) + return func + +@register +def f1(): + print("running f1") + +@register +def f2(): + print("running f2") + + +def f3(): + print("running f3") + + +def main(): + print("running main") + print("registry -> ", registry) + f1() + f2() + f3() + + # if __name__ == "__main__": + # main() + + + +import time + + + +def clock(func): + print("toto") + def clocked(*args): + t0 = time.perf_counter() + result = func(*args) + elapsed = time.perf_counter() - t0 + name = func.__name__ + arg_str = ', '.join(repr(arg) for arg in args) + print('[%0.8fs] %s(%s) -> %r' % (elapsed, name, arg_str, result)) + return result + return clocked + + + + + +@clock +def snooze(seconds): + time.sleep(seconds) + + + +@clock +def factorial(n): + return 1 if n < 2 else n*factorial(n-1) + + + +if __name__ == "__main__": + main() + print('*' * 40, 'Calling snooze(.123)') + snooze(.123) + print('*' * 40, 'Calling factorial(6)') + print('6! =', factorial(6)) \ No newline at end of file diff --git a/metropolitain_LMO.py b/metropolitain_LMO.py index e3d58c6..dbe05a8 100644 --- a/metropolitain_LMO.py +++ b/metropolitain_LMO.py @@ -4,7 +4,8 @@ from bs4 import BeautifulSoup import requests -data= [] +stationslist= [] +lineslistlist= [] url = r"https://en.wikipedia.org/wiki/List_of_stations_of_the_Paris_M%C3%A9tro" response = requests.get(url) soup_page = BeautifulSoup(response.content,"html.parser") @@ -12,16 +13,17 @@ for soup_line in soup_table.findAll('tr'): indice = 0 station= "" - linelist= [] + lineslist= [] for soup_case in soup_line.findAll('td'): for soup_station in soup_case.findAll('a'): if(indice == 0): station = soup_station.string if(indice ==3): - linelist.append(soup_station.string) + lineslist.append(soup_station.string) indice += 1 if not station == "": - tmp = [station, linelist] - data.append(tmp) + stationslist.append(station) + lineslistlist.append(lineslist) +dic=dict(zip(stationslist, lineslistlist)) -print(data) +print(dic) diff --git a/templates/404.html b/templates/404.html new file mode 100644 index 0000000..41103b7 --- /dev/null +++ b/templates/404.html @@ -0,0 +1,8 @@ + + +
+ +Your browser is {}
'.format(user_agent) + #return '