Skip to content

Instantly share code, notes, and snippets.

@neriberto
Created June 5, 2014 13:49
Show Gist options
  • Save neriberto/1f1533e8578ed595e86e to your computer and use it in GitHub Desktop.
Save neriberto/1f1533e8578ed595e86e to your computer and use it in GitHub Desktop.
Descobre o maior caminho no sistema operacional
import os
sizepath = 0;
longpath = None;
def calc(path):
global longpath
global sizepath
length = len(path)
if length > sizepath:
sizepath = length
longpath = path
def walk(path):
for dirname, dirnames, filenames in os.walk(path):
for subdirname in dirnames:
calc(os.path.join(dirname, subdirname))
for filename in filenames:
calc(os.path.join(dirname, filename))
walkin = "C:\\"
walk(walkin)
print "O caminho maior encontrado foi de %s caracteres" % sizepath
print "O caminho : %s" % longpath
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment