Perl, Java, Python
Rafe Colburn writes something in Perl, then explains that you have to be a pretty good Perl coder to be able to read it. And then he rewrites it in Java, using many more lines but making it much more readable.
So of course, here's the Python version:
Still one line, but it also makes sense. And if you want it to be cross-platform:
How's that for readability?
This is the fun thing about Python: it already does what you want. "Batteries Included."
So of course, here's the Python version:
if depth: depth += datadir.count('/') - 1
Still one line, but it also makes sense. And if you want it to be cross-platform:
import os
if depth:
depth += datadir.count(os.sep) - 1
How's that for readability?
This is the fun thing about Python: it already does what you want. "Batteries Included."