Sort and remove duplicates stations in list_stations() - lefrecce - Retrieve information about next trains and stations via lefrecce.it
(HTM) hg clone https://bitbucket.org/iamleot/lefrecce
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) README
---
(DIR) changeset d63ff3273ed34e3f4c434f52c5fce922bdca135d
(DIR) parent cd423fe0868279d6916ade15b3dad14f03019343
(HTM) Author: Leonardo Taccari <iamleot@gmail.com>
Date: Sat, 17 Feb 2018 20:42:07
Sort and remove duplicates stations in list_stations()
Initally define stations as a set(), add every station to it and then convert to
a list and sort it.
Diffstat:
lefrecce.py | 7 +++++--
1 files changed, 5 insertions(+), 2 deletions(-)
---
diff -r cd423fe08682 -r d63ff3273ed3 lefrecce.py
--- a/lefrecce.py Sat Feb 17 19:58:22 2018 +0100
+++ b/lefrecce.py Sat Feb 17 20:42:07 2018 +0100
@@ -147,9 +147,12 @@
res += l.decode()
j = json.loads(res)
- stations = []
+ stations = set()
for station in j:
- stations.append(list(station)[0])
+ stations.add(list(station)[0])
+
+ stations = list(stations)
+ stations.sort()
return stations