My favorites | Sign in
Project Home
Search
for
Coding_Guideline  

Featured
Updated Jul 8, 2011 by diego.sarmentero

Coding Guideline

  • Do not put Your name in the Files you edit, the source code is made by all of us!
  • Do NOT use str(), use instead: unicode()
  • Respect Margin at 80th character (PEP8).
  • Write CONSTANTS names in upper case.
  • Comment: your code! (if you didn't comment your code: GOTO Comment)
  • Imports order:
    • from future import absolute_import
    • Python Base Modules
    • Third Party Modules
    • NINJA modules
  • Be PEP8 Compliant (NINJA-IDE helps you with this!)
  • Remove trailing whitespaces and include a blank line at the end of the file (NINJA-IDE helps you with this too!)
  • Use Qt Translation for Text in the UI, for example:
  • self.tr("$1 text with param", "NINJA-IDE")
    # "$1" represents a parameter that is going to be included in the String
  • If your Classes are going to emit signals, please comment that in the header of the Class like this:
  • class Editor(QPlainTextEdit, itab_item.ITabItem):
    
    ###############################################################################
    # EDITOR SIGNALS
    ###############################################################################
        """
        cursorPositionChanged()
        modificationChanged(bool)
        fileSaved(QPlainTextEdit)
        locateFunction(QString, QString, bool) [functionName, filePath, isVariable]
        openDropFile(QString)
        """
    ###############################################################################

(example: Editor Header)

  • Always import modules, not class or functions directly (Except for Qt because every class starts with "Q" so its procedence is obvious)
  • #For example: IDE Module (NINJA-IDE)
    from ninja_ide.gui import ide
    ide.start()  #Call a Function
    instance = ide.IDE()  #Instance from Class
    
    #For Qt:
    from PyQt4.QtGui import QWidget
    w = QWidget()
    
    #Never:
    from ninja_ide.gui.ide import IDE
    instance = IDE()  #Wrong! Not very intuitive!
Powered by Google Project Hosting