2013/6/20 Serhiy Storchaka <storch...@gmail.com>: > Now with enumerations in the stdlib the stat module constants are candidates > for flag enumerations. How easy will be implement it on C?
Numerical values are less important than S_ISxxx() macros. Example: #define S_ISDOOR(mode) (((mode)&0xF000) == 0xd000) 0xd000 is (stat.S_IFSOCK + stat.S_IFIFO). And how do you represent the file mode with enums? I don't think that enum should be used in the stat module. I would prefer a stat object with methods than having to calls low-level functions. Something like: os.stat("document.txt").st_mode.is_reg() versus stat.S_ISREG(os.stat("document.txt").st_mode) The idea was discussed in http://bugs.python.org/issue11406 to solve a real API design issue. How should os.scandir() return the "is a directory" information with a portable API. I'm not saying that stat.S_ISREG should go away. The two approaches are complementary. Victor _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com