Does python have a “use strict;” and “use warnings;” like in perl?

后端 未结 6 1619
刺人心
刺人心 2021-02-02 05:27

I am learning perl and python... at the same time, not my by design but it has to be done.

Question:

In a perl script I use(see below) at the head of my txt.

6条回答
  •  孤城傲影
    2021-02-02 06:10

    LeoNerd's provides a great explanation as to why there is no 'use strict' or 'use warnings' in Python.

    In answer to:

    Is there something I should be doing on routine for my python scripts?

    You may be interested in running your code through a static code analyser like pylint, and/or a code formatting check such as pep8.

    They can help to find potential problems, and flag warnings. They also have a lot to say about the formatting of your code, which you may or may not be interested in.

    Here is a decent rationale for their use. And related Stackoverflow questions here and here.

提交回复
热议问题