Advertisement
Guest User

Untitled

a guest
May 23rd, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. @staticmethod
  2. def from_file(stations):
  3. trains = []
  4. f = open("metro.txt", encoding='utf-8')
  5. for line in f.readlines():
  6. if not line: break
  7. data = line.split()
  8. n, s, d, sp, c = '', '', '', '', ''
  9. if len(data) == 5:
  10. n, s, d, sp, c = data
  11. elif len(data) == 6:
  12. n, s1, s2, d, sp, c = data
  13. s = s1 + s2
  14. s = stations[s]
  15. trains.append(Train(
  16. n, s, d, sp, c, stations
  17. ))
  18. return trains
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement