O'Reilly logo

Learning Python Design Patterns by Gennadiy Zlobin

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Facades in Python's standard library

Facades can often be found in Python's source code.

The isdir function found in the os.path module serves as a Facade outshining work stat and os.stat modules. Internally isdir calls the os.stat function and that function in turn calls the stat() system call on the given path. This system call returns a structure with members, namely:

  • st_mode: This indicates some protection bits
  • st_size: This is the size of the file, in bytes
  • st_atime: This is the time of the most recent access

stat.S_ISDIR internally applies a bit mask S_IFMT to detect if the file passed by is actually a directory. This looks pretty confusing, but the good news is that the end user of this function does not need to know these intricacies. The ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required