SpecialistOff.NET / Вопросы / Статьи / Фрагменты кода / Резюме / Метки / Помощь / Файлы
НазадМетки: python
Using zip() and dealing with two or more elements at a time:
['%s=%s' % (n, v) for n, v in zip(self.all_names, self)]
Multiple types (auto unpacking of a tuple):
[f(v) for (n, f), v in zip(cls.all_slots, values)]
A two-level list comprehension using os.walk():
# Comprehensions/os_walk_comprehension.py import os restFiles = [os.path.join(d[0], f) for d in os.walk(".") for f in d[2] if f.endswith(".rst")] for r in restFiles: print(r)