[alsa-devel] [PATCH - hwmixvolume 4/9] hwmixvolume: use a with context to open files

Takashi Sakamoto o-takashi at sakamocchi.jp
Wed Aug 15 17:36:06 CEST 2018


On Aug 14 2018 12:59, Takashi Sakamoto wrote:
> If you use Python 2.5 or later, you can use 'file()' instead of 
> 'open()'. Furthermore, FILE object returned by 'file()' (or 'open()') 
> supports 'iterator' and you have no need to call '.readlines()' anymore,
> thus:
> 
> ```
>  > +            with file(filename, "r") as f:
>  > +                for line in f:
> ...
> ```

Oops. The 'file()' is removed at Python 3.0[1]...

[1] https://docs.python.org/release/3.0/whatsnew/3.0.html#builtins


Regards

Takashi Sakamoto


More information about the Alsa-devel mailing list