Advertisement
Guest User

Untitled

a guest
Mar 22nd, 2017
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1.  
  2. #I figured I should create code that finds the path of the music file since
  3. #the used is able to move it around and it would just have more flexability if
  4. #user would be able to do that. Found an example @ Stackoverflow and modified it
  5. #so that it would search the file system for our music file.
  6.  
  7. def find(pattern, path):
  8. result = []
  9. for root, dirs, files in os.walk(path):
  10. for name in files:
  11. if fnmatch.fnmatch(name, pattern):
  12. result.append(os.path.join(root, name))
  13. return result
  14.  
  15. path_to_file = find('music.dat', '/home/')
  16.  
  17. path_for_block = path_to_file[0]
  18.  
  19.  
  20. #??? I'm really confused about this part.
  21.  
  22. #this outputs the path in this format ['/home/maris/Downloads/music.dat']
  23. #print(path_to_file)
  24.  
  25. #while this outputs the path in this format /home/maris/Downloads/music.dat
  26. #print(path_to_file[0])
  27.  
  28. #why?
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement