I'm beginner in python and hope you help me find way to write if statement correctly. This is code i have:
target_dir = Path(__file__).resolve().parents[1]
nav_files = [
x
for x in target_dir.rglob('conf.yaml')
if '.'.join(str(x.parent).replace(str(target_dir), '').lstrip('/').split('/')[:2]) in settings.MODULES
]
You may see unacceptably long if statement. As i understand there are 2 ways to resolve this:
- Separate
nav_filespreparation and use someforblocks - Separate
ifstatement by linebreaks(if it's possible)
What is the best practice? Thanks!
Aucun commentaire:
Enregistrer un commentaire