techhub.social is one of the many independent Mastodon servers you can use to participate in the fediverse.
A hub primarily for passionate technologists, but everyone is welcome

Administered by:

Server stats:

4.9K
active users

RecursiveNeuron :verified:

🐍 Single cmd,find what is max number of lines of code in a single file of your project

▶️ Let's know what is max no.of lines in your project

python3 -c "import pathlib; print(max(len(p.read_text().splitlines()) for p in pathlib.Path().rglob('*.py')))"

*There are easier ways than this in though

@RecursiveNeuron I think I would have used

`from pathlib import Path; lines_file = ((len(p.read_text().splitlines()), p) for p in Path().rglob(‘*.py’)); print(max(lines_file))`

It seems like the lines_file generator can then be used for other things. This might help show ways python can be superior to the shell.