Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change default python coding style

Tags:

In python i'm following camelCase Naming style. I checked my code with "pylint" and it gives error for not following lower_case_with_underscores style. Also i use netBeans IDE for coding. This IDE gives warning for not following lower_case_with_underscores style.

How to tell pylint and netBeans that i'm following camelCase naming style, not lower_case_with_underscores??

Thanks.

like image 785
Netro Avatar asked Mar 07 '11 14:03

Netro


People also ask

What is a coding style in Python?

There are four main Python coding styles: imperative, functional, object-oriented, and procedural. (Some people combine imperative and functional coding styles while others view them as completely separate styles.)

What is PEP 8 style in Python?

PEP 8, sometimes spelled PEP8 or PEP-8, is a document that provides guidelines and best practices on how to write Python code. It was written in 2001 by Guido van Rossum, Barry Warsaw, and Nick Coghlan. The primary focus of PEP 8 is to improve the readability and consistency of Python code.


1 Answers

Use pylint --generate-rcfile > ~/.pylintrc to get a standard pylintrc.

Edit the file, go to the [BASIC] section, and change the following regexps:

  • function-rgx=_?_?[a-z][A-Za-z0-9]{1,30}$
  • method-rgx=_?_?[a-z][A-Za-z0-9]{1,30}$
  • attr-rgx=_?_?[a-z][A-Za-z0-9]{1,30}$
  • argument-rgx=_?[a-z][A-Za-z0-9]{1,30}$
  • variable-rgx=_?[a-z][A-Za-z0-9]{1,30}$
  • inlinevar-rgx=_?[a-z][A-Za-z0-9]{1,30}$

You may also want to change module-rgx while you are at it, and look around for other settings that you may want to customize to suite your style.

like image 157
gurney alex Avatar answered Dec 07 '22 22:12

gurney alex