Entry 959
Will's make_path
Submitted by Adam Collard
on Aug. 25, 2008 at 3:31 p.m.
Language: Python. Code size: 489 bytes.
import os.path FILE_LIMIT = 50 def _get_dirs(x): """Recursive helper to get list of directories""" if x == 0: return elif x < FILE_LIMIT: yield str(x) else: div, mod = divmod(x, FILE_LIMIT) for directory in _get_dirs(div): yield directory yield str(mod) def make_path(n): div, mod = divmod(n, FILE_LIMIT) path = list(_get_dirs(div)) + ["%s.file" % mod] return os.path.join(*path)
This snippet took 0.00 seconds to highlight.
Back to the Entry List or Home.