1

SORRY FOR MY BAD ENGLISH I searched for code thats not show the files which invisible on 'windows explorer' but visible on 'os.listdir(path)', and I have got this code:

if os.name == 'nt':
    import win32api, win32con


def folder_is_hidden(p):
    if os.name== 'nt':
        attribute = win32api.GetFileAttributes(p)
        return attribute & (win32con.FILE_ATTRIBUTE_HIDDEN | win32con.FILE_ATTRIBUTE_SYSTEM)
    else:
        return p.startswith('.') #linux-osx
print  folder_is_hidden('path')

I understood that the return value is True if its invisible and False if isnt. But - I want to understand exactly how it works.

I want to understand this code and its purpose line by line.

dfsfg sfg
  • 77
  • 1
  • 9
  • is there a particular part you don't understand? is it the first `if`? – depperm Sep 22 '16 at 20:17
  • @depperm Actually, I know that the 'nt' used to check if im on windows or not. I didnt understood the 'GetFileAttributes' and the doing "BitWise" thing between the attribute and the two other things... – dfsfg sfg Sep 22 '16 at 20:47
  • see http://stackoverflow.com/a/12131595/3462319 – depperm Sep 22 '16 at 21:01

0 Answers0