Pylint Tutorial - How to Write Clean Python

แชร์
ฝัง
  • เผยแพร่เมื่อ 5 ต.ค. 2024
  • dbader.org/pyt... ► Get examples of clean and Pythonic code that passes any Pylint or PEP 8 run.
    In this Pylint tutorial video you'll see how to install and set up the Pylint code linter for Python step by step. We'll go over why you should use a code linter like Pylint, Flake8, Pyflakes, or other static analysis tools-and how they can help you write cleaner and more Pythonic code.
    Pylint is a well-known static analysis tool for Python 2 and 3. It has a number of useful features, like checking your code for compliance with the PEP 8 Python style guide. It makes sure that your code follows the code style guide and it can also automatically identify common bugs and errors in your Python code.
    To set up Pylint you'll first need to install it with the `pip install` command and then you can run it on any Python file with the "pylint" command. Pylint inspects your code and then gives you feedback on it. Besides running Pylint from the command-line you can also integrate it into your editor to get live feedback on your Python code.
    In this Pylint tutorial I'm going over the feedback produced by Pylint and I'm taking it to refactor and improve the quality of my code. You can get this setup up and running in a few minutes and it'll quickly help you write better and cleaner Python code.
    FREE COURSE - "5 Thoughts on Mastering Python" dbader.org/pyt...
    SUBSCRIBE TO THIS CHANNEL: dbader.org/you...
    * *
    ► Python swag: MUGS, SHIRTS & more: nerdlettering.com
    FREE Python Tutorials & News:
    » Python Tutorials: dbader.org
    » Python News on Twitter: / @dbader_org
    » Weekly Tips for Pythonistas: dbader.org/new...
    » Subscribe to this channel: dbader.org/you...

ความคิดเห็น • 72

  • @drew4980
    @drew4980 7 ปีที่แล้ว +49

    My new favorite python youtuber! Really love how you're bridging the gap between beginner and intermediate. Not many other people do that very well but you're nailing it.

    • @realpython
      @realpython  7 ปีที่แล้ว +4

      Thank you for the kind words! :-)

  • @noinformationavailable4114
    @noinformationavailable4114 6 ปีที่แล้ว +6

    I had so much trouble understanding python until i saw your videos! You turned my crappy unclean and duct taped code into something nice and presentable!!

    • @realpython
      @realpython  6 ปีที่แล้ว +2

      That's great to hear! I'm glad the videos have been helpful to you. :-)

  • @egimessito
    @egimessito 2 ปีที่แล้ว

    read...actually studied your book. Finally going deep is now easy to understand how to go from cs or java to py. Well done and thank you

  • @JoshEnglish
    @JoshEnglish 7 ปีที่แล้ว +14

    The score is based on the number of errors and the number of lines. 10 is "perfect" and there is no lower bound to the score.

  • @sepehrnematollahi1151
    @sepehrnematollahi1151 2 ปีที่แล้ว

    Thanks for putting a little content between all the ads!

  • @cybersphere
    @cybersphere 4 ปีที่แล้ว +4

    If you use Visual Studio Code, Pylint is included by default. You just have to give installation permission. Style errors are then highlighted automagically.

    • @dineshsadhwani3717
      @dineshsadhwani3717 ปีที่แล้ว

      Automagically? You mean automatically?

    • @cybersphere
      @cybersphere ปีที่แล้ว +2

      @@dineshsadhwani3717 No, automagically. It combines the words automatic and magically and means automatically in a way that seems magical.

  • @RobinTheHoodedMan
    @RobinTheHoodedMan 7 ปีที่แล้ว +1

    Great video. As a Python noobie I'm still finding out all the wrinkles, and finding out about helpful programming tools, and seeking the 'ultimate' IDE for Python (lol). Succint and to the point, nice one. Now I'm subscribed!!

    • @realpython
      @realpython  7 ปีที่แล้ว

      Thanks! I hope I can continue to help you on your journey through Python!

  • @MrVictorock
    @MrVictorock 7 ปีที่แล้ว +2

    You should do videos about job interview in python too...for example: What a python developer must know before a job interview?

    • @youwouldbetterfuckme
      @youwouldbetterfuckme 6 ปีที่แล้ว

      This question disqualifies a candidate IMHO.

    • @jamesuejio2787
      @jamesuejio2787 4 ปีที่แล้ว

      realpython.com/python-coding-interview-tips/ :D We will have a related video walkthrough attached to the video in the next coming months.

  • @satoshinakamoto171
    @satoshinakamoto171 5 ปีที่แล้ว

    thanks ur great. please keep making videos ...ur helping the community alot with ur helpful videos.

    • @realpython
      @realpython  5 ปีที่แล้ว

      Thanks for the kind words!

  • @kennyPAGC
    @kennyPAGC 6 ปีที่แล้ว +8

    pylint missed the triple whitespace between the keyword def and the function name crash

  • @webapplicationguide3798
    @webapplicationguide3798 7 ปีที่แล้ว

    Thanks Dan for all those tips.

  • @harshmishra8990
    @harshmishra8990 4 ปีที่แล้ว

    Thanks for such amazing tutorials.

  • @Zinzin09
    @Zinzin09 7 ปีที่แล้ว

    Wondering how you edited your terminal window removing the title bar??? Great video! Keep it up with the great content!

    • @realpython
      @realpython  7 ปีที่แล้ว +2

      It's a setting in iTerm2 (remove border or something like that).

  • @shahrokhabbasirad2223
    @shahrokhabbasirad2223 5 ปีที่แล้ว

    I really enjoyed. This video is AWESOME

    • @realpython
      @realpython  5 ปีที่แล้ว

      Thanks for the kind words!

  • @sergeydeluxe
    @sergeydeluxe 4 ปีที่แล้ว

    Great tutorial! Thank you!

  • @philtoa334
    @philtoa334 ปีที่แล้ว

    it was time for u to use that 🤣.
    Thanks really nice vid.

  • @iaroslavdavydiak6439
    @iaroslavdavydiak6439 2 ปีที่แล้ว

    Awesome. Thank you!

  • @dmytroohorodnik3562
    @dmytroohorodnik3562 4 ปีที่แล้ว +3

    You can run "pylint pylint" :)

  • @Danny-uq9zf
    @Danny-uq9zf 4 ปีที่แล้ว

    What shell is that!? Please make a video on installing and customizing that terminal/shell!

  • @ivanlaplante
    @ivanlaplante 3 ปีที่แล้ว +1

    3:26 Could anyone tell me in which context he recommends using vEnv? To install any (surf?) Python tool/dependency?

  • @ArturdeSousaRocha
    @ArturdeSousaRocha 5 ปีที่แล้ว

    Personally I prefer to leave pylint as it is and only disable specific messages to indicate that I had a good reason to do something and it's not an error. Interestingly, VS Code disables almost all pylint messages by default.

  • @tarekhesham5133
    @tarekhesham5133 7 ปีที่แล้ว

    Thank you very much for these great tips.

    • @realpython
      @realpython  7 ปีที่แล้ว

      You're welcome :-)

  • @angelluisgarciaguzman5598
    @angelluisgarciaguzman5598 4 ปีที่แล้ว

    It just works!

  • @ayushtripathi1125
    @ayushtripathi1125 4 ปีที่แล้ว +1

    I know I'm three years late, but I'm new to python and I would appreciate some help. I successfully installed pylint, but when I do "pylint [full path of file name]" command prompt says pylint is not recognized as an internal or external command. Please help, thanks!

    • @compphysgeek
      @compphysgeek 4 ปีที่แล้ว

      looks like pylint is not in your path, so you must either update your path variable with the location of pylint or call pylint also with its full path

  • @malic_zarith
    @malic_zarith 5 ปีที่แล้ว

    I have a question. A bunch of people say to work 6 hours a day if one wants to learn programming for a job. I only work four hours a day. This includes also working 4 hours on weekends. Is that enough, or should I start doing 6?

    • @realpython
      @realpython  5 ปีที่แล้ว

      Yes, that is enough. Some people only manage about an hour a day, as long as you are consistent with it, you will find yourself progressing.

    • @malic_zarith
      @malic_zarith 5 ปีที่แล้ว

      @@realpython Ok that's good

  • @petrockspiracy3120
    @petrockspiracy3120 4 ปีที่แล้ว

    Can anyone explain to me why I get a mixed-indentation error for using tabs only when I haven't used spaces? If I just use spaces it's okay but surely no one actually types out four spaces... I don't get it.
    Edit: okay I just did adjusted the option at the bottom right of the window to be spaces and it converts them for you

  • @3ckortreat
    @3ckortreat 3 ปีที่แล้ว

    how did you make your terminal frameless??

  • @maukaladka4100
    @maukaladka4100 3 ปีที่แล้ว

    Nice one

  • @banderilllero
    @banderilllero 4 ปีที่แล้ว

    so is this equivalent to Misra checker?

  • @malharjajoo7393
    @malharjajoo7393 5 ปีที่แล้ว

    Nice tutorial.

  • @VenkateshwaraDoijode
    @VenkateshwaraDoijode 4 ปีที่แล้ว

    How to save pylint example.py console output to text file ?

  • @budi0580
    @budi0580 2 ปีที่แล้ว +1

    Is this tutorial still relevant today ?

  • @sumitkumarsain5542
    @sumitkumarsain5542 5 ปีที่แล้ว

    Hi Dan. Do u have a playlist for python tutorials!! Thanks, Sumit

    • @realpython
      @realpython  5 ปีที่แล้ว +1

      I have a few playlists available, you can check them out here: th-cam.com/channels/I0vQvr9aFn27yR6Ej6n5UA.htmlplaylists

  • @EnglishRain
    @EnglishRain 4 ปีที่แล้ว

    13:00 - didn't realize we had to uppercase base level variables.

    • @bfdhtfyjhjj
      @bfdhtfyjhjj 4 ปีที่แล้ว +1

      Hes wrong. You need to use uppercase because its not variable, its a constat.

    • @EnglishRain
      @EnglishRain 4 ปีที่แล้ว

      @@bfdhtfyjhjj Thanks for correcting me.

  • @swadhikarc7858
    @swadhikarc7858 4 ปีที่แล้ว +2

    Line 14 has more spaces between def and function name, still a perfect code 😂

  • @vighnesh153
    @vighnesh153 5 ปีที่แล้ว +3

    Or use PyCharm

    • @vighnesh153
      @vighnesh153 3 ปีที่แล้ว

      @Peter Mortensen it has builtin pep8 checks.

  • @vaneakatok
    @vaneakatok 5 ปีที่แล้ว

    I can't find a way, I mean a video on generating UMLs
    Do you have are intend to do any?

  • @atefehnasiran1294
    @atefehnasiran1294 4 ปีที่แล้ว +1

    I wanted to pylint one of my files butvI had SyntaxError: invalid syntax
    what can I do?

  • @lumed2189
    @lumed2189 4 ปีที่แล้ว

    Pylint👍👍😍

  • @elhamzeinodini4828
    @elhamzeinodini4828 3 ปีที่แล้ว

    💥💥💥

  • @jimgolab536
    @jimgolab536 2 ปีที่แล้ว +1

    Lint = Lexical Interpreter.

  • @Albin_Evald
    @Albin_Evald 4 ปีที่แล้ว

    after watching for 17 minutes, 17:07.... DOH

  • @CryptoPi_314
    @CryptoPi_314 5 ปีที่แล้ว

    If possible can you plz. make a video on 'Design Patterns with Python': en.wikipedia.org/wiki/Design_Patterns#Patterns_by_Type :)

    • @gshan994
      @gshan994 2 ปีที่แล้ว

      Arjan codes is a youtube channel to check for design patterns with python

  • @amberlong1354
    @amberlong1354 5 ปีที่แล้ว

    me too.

  • @oxygenist
    @oxygenist 3 ปีที่แล้ว

    .

  • @yuverris
    @yuverris 4 ปีที่แล้ว

    nice pylint ruined my whole day

  • @jonathanmoore5619
    @jonathanmoore5619 4 ปีที่แล้ว

    Concentrate on creating... Python... Literally the snake eating it's own tail...

    • @jonathanmoore5619
      @jonathanmoore5619 3 ปีที่แล้ว

      @Peter Mortensen I rest my case... Some make, some check, some do nothing at all.

  • @inftertainment
    @inftertainment 5 ปีที่แล้ว +1

    Running ‘pip install pylint’ in terminal gets me nothing but ‘-bash: pip: command not found’

    • @KishoreKumar-is3qn
      @KishoreKumar-is3qn 5 ปีที่แล้ว

      install pip

    • @AtlantaTerry
      @AtlantaTerry 5 ปีที่แล้ว

      @@KishoreKumar-is3qn thanks, but noobs might not know how.