The tools I use to write python code.

There are 3 replies in this Thread which was already clicked 963 times. The last Post () by KiddaC.

  • As I often get asked by other coders and plugin developers to check their code as its not working and they don't know why.
    Basically I go through the same motions every time which usually highlights their errors.


    Which is basically load it in my software. Look for any compile errors. Look for any Linting errors.
    Fix those errors and warning, then everything usually works.

    Sometimes its not that simple and requires a full debug, but most of the time it is that simple error that is breaking things.

    ** A person who feels appreciated will always do more than what is expected **

  • If it helps this is how I work.


    I have python 3 installed in my windows machine. I am currently using 3.10.

    This lives in my windows Program Files folder


    Download Python
    The official home of the Python Programming Language
    www.python.org


    I use Geany as my python text editor. (I find Visual Studio Community edition too bulky for python code. Notepad++ is not as good as Geany for python.)
    https://www.geany.org/download/releases/


    I have installed pylama as my python/geany linting program


    open a windows powershell (run as admin)

    use the command below to install pylama
    pip install pylama

    pasted-from-clipboard.png



    Then in Geany I have these settings. Build/Set build commands


    [Compile] python -m py_compile "%f"

    [Full lint] pylama --max-line-length=800 --ignore=E722,W605,C901 "%f"


    pasted-from-clipboard.png


    Now on my setup

    clicking compile will highlight any code errors.

    clicking f9 - will do a full lint - and highlight anything else that needs amending

    pasted-from-clipboard.png


    Other useful commands in Geany

    pasted-from-clipboard.png


    For your home setup you would also have to install any common python libraries you use i.e requests using the "pip install ...." command in windows powershell

    Just search https://pypi.org/ for the library and pip command

    ** A person who feels appreciated will always do more than what is expected **

  • Common linting mistakes


    Start each python document with the following, just to be safe

    Python
    #!/usr/bin/python
    # -*- coding: utf-8 -*-
    blank line


    Lines too long - anything inside brackets can be split over multiple lines. Anything not in brackets can be split with \


    Modern python you should use spaces(4) and not tabs.


    Your code should have

    No space before a colon (:)

    test1: (correct)
    test2 : (incorrect)


    Space after a colon (:)

    test1: item (correct)

    test2:item (incorrect)


    Space after comma seperated items. i.e

    test1, test2 (correct

    test1,test2 (incorrect)


    Space around arithmetic operators.

    1 + 1 (correct)

    1+1 (incorrect)


    Comment should have a space after the #

    # correct

    #incorrect


    Inline comments should have 2 spaces before.


    some text  # inline comment correct

    some text # inline comment incorrect


    Check the indentation of your code. A good linting program will highlight indentation issues.

    Another reason why you should use 4 spaces instead. Tabs can do different things in different text editors.

    Dont mix tabs and spaces - this will not compile

    ** A person who feels appreciated will always do more than what is expected **

  • The Zen of Python, by Tim Peters


    Beautiful is better than ugly.
    Explicit is better than implicit.
    Simple is better than complex.
    Complex is better than complicated.
    Flat is better than nested.
    Sparse is better than dense.
    Readability counts.
    Special cases aren't special enough to break the rules.
    Although practicality beats purity.
    Errors should never pass silently.
    Unless explicitly silenced.
    In the face of ambiguity, refuse the temptation to guess.
    There should be one-- and preferably only one --obvious way to do it.
    Although that way may not be obvious at first unless you're Dutch.
    Now is better than never.
    Although never is often better than *right* now.
    If the implementation is hard to explain, it's a bad idea.
    If the implementation is easy to explain, it may be a good idea.
    Namespaces are one honking great idea -- let's do more of those!


    7 Key Takeaways from the Zen of Python
    In this article, you'll take a look at the different rules of thumb posited by the Zen of Python, as well as how to implement them in your development workflow.
    initialcommit.com

    ** A person who feels appreciated will always do more than what is expected **

KiddaC Skins and Plugins

KiddaC Enigma2 Picons, Plugins and Skins, includes slyk-1-HD, v-skin-HD, slyk-q-HD, slyk onyx skins, Bouquet Maker Xtream, E2Piconizer, IPTV Bouquet Maker, Jedi Maker Xtream, Jedi EPG Xtream, ScreenNames, Visual Weather and X Class, X-Streamity - Xtream Codes IPTV Player.

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!