Benefits of os.path.splitext over regular .split?

前端 未结 11 955
独厮守ぢ
独厮守ぢ 2020-12-08 13:16

In this other question, the votes clearly show that the os.path.splitext function is preferred over the simple .split(\'.\')[-1] string manipulatio

11条回答
  •  再見小時候
    2020-12-08 14:05

    I am not sure Python has been ported on the VMS platform, but assuming it did (*):

    • Filenames are typically of the format: $device-dir-subdir$filename.$type;$version (**)

    I hope you realize that using a narrow-scope method, which is only influenced by the systems you are exposed on, isn't optimal for long-term code maintainability and such practices are particularly detrimental to mixing and matching disparate software components in larger software projects.

    Essentially, in the latter case the success probability (dependability) is akin to

    R(t)=1-(1-Ri)^n

    and you can now see how poor/incomplete software implementations result into buggy programs. More broadly speaking, porting software is difficult precisely due to such bugs.

    (*) hm, googling revealed quickly about: https://www.vmspython.org
    (**) Check at the regex wars over here! https://stackoverflow.com/a/4465456/1574494

提交回复
热议问题