Can global variable be passed into Python function?

Marko Rauhamaa marko at
Sun Mar 2 10:40:05 CET 2014

Marko Rauhamaa <marko at>:

> If I take the API documentation on its face value, [...]
> I *must* use "is" for os.POSIX_FAVD_*:
>     if fsavd_flag is os.POSIX_FADV_RANDOM:
>         ...

However, since a documentation flaw is more than likely, it is even more
prudent to avoid both "==" and "is" and create a set of shadow constants
in the application code:

      if self.fsavd_flag is self.FAVD_RANDOM:
          os.posix_fadvice(fd, offset, len, os.POSIX_FAVD_RANDOM):


More information about the Python-list mailing list