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

后端 未结 6 1662
刺人心
刺人心 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:12

    To run Python with warnings turned on:

    python -W all file.py
    

    In response to:

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

    I think it's generally a good idea to make sure your code is compliant with PEP 8. As alluded to in another answer, you can do this programatically:

    pip install pep8 && pep8 file.py
    

提交回复
热议问题