25 nooby Python habits you need to ditch

初心者

Nooby Python habits give away your inexperience.

Improve your code and your prestige just a bit by ditching those habits and doing things the Pythonic way.

CONTEST CLOSED! The winners are: Lluc Cardoner, David Saint, Gaurav Verma 1412, and Alpe!

OFFICIAL CONTEST RULES:
1. All entries must comply with the YouTube community guidelines ( http://www.youtube.com/t/community_guidelines) and YouTube Terms of Service (http://www.youtube.com/static?gl=US&template=terms). Entries that violate YouTube guidelines are automatically disqualified.
2. YouTube is not a sponsor of the contest and viewers are required to release YouTube from any liability related to the contest.
3. Privacy notice: no personal data will be collected for this contest.
4. In order to enter, you must (a) be one of my subscribers, AND (b) make a top-level comment to the video including #pycharm somewhere in the comment.
5. The contest is free, there is no fee required to enter.
6. Winners will be chosen randomly 1 week after the date the video went live from all users who have entered and not been disqualified.
7. Each winner will be notified via a comment reply from me that details what prize was won (e.g. “Congratulations! You have won XYZ. Please email me.”). I will ask the winner to contact me by email, and I will reply through email with a random token which must be posted as another reply to the winning comment from the winning account in order to verify account ownership and prevent fraud.
8. Each winner will have 72 hours to respond AND prove account ownership or their prize is automatically forfeited and another winner will be chosen.
9. A winner can only win 1 prize per contest.
10. The prize pool for this contest is: 4 licenses for PyCharm Professional (“Free 1-Year Personal Subscription”), which is a product made by JetBrains. A prize consists of 1 license, which will be delivered in the form of a redeemable code that can be redeemed at https://www.jetbrains.com/store/redeem/ before May 01, 2022.
11. You may not enter the contest if doing so would be a violation of any relevant federal, state, and local laws, rules, and regulations, including U.S. sanctions.

― mCoding with James Murphy (https://mcoding.io)

Source code: https://github.com/mCodingLLC/VideosSampleCode

SUPPORT ME ⭐
—————————————————
Patreon: https://patreon.com/mCoding
Paypal: https://www.paypal.com/donate/?hosted_button_id=VJY5SLZ8BJHEE
Other donations: https://mcoding.io/donate

Top patrons and donors: Jameson, Laura M, Dragos C, Vahnekie, John Martin, Casey G, Pieter G, Krisztian M, Mutual Information, Sigmanificient

BE ACTIVE IN MY COMMUNITY 😄
—————————————————
Discord: https://discord.gg/Ye9yJtZQuN
Github: https://github.com/mCodingLLC/
Reddit: https://www.reddit.com/r/mCoding/
Facebook: https://www.facebook.com/james.mcoding

コメント

  1. Apple of the Ground より:

    1. 00:25: Manual string formatting
    2. 00:36: Manually closing a file
    3. 00:53: Using “try:” and “finally:” instead of a context manager
    4. 01:07: Using a bare “except:” clause
    5. 01:32: Thinking that “^” in python means exponentiation (it’s a bitwise XOR, exponentiation is “a ** b”)
    6. 01:42: Use of default mutable arguments
    7. 02:07: Never using comprehensions, or only using list comprehensions
    8. 02:24: ALWAYS using comprehensions
    9. 02:50: Checking for a type using “==”
    10. 03:23: Using “==” to check for None, True, or False
    11. 03:37: Using an “if bool(x):” or “if len(x)” check
    12. 03:51: Using the “range(len(a))” idiom
    13. 04:30: Looping over the keys of a dictionary
    14. 04:48: Not knowing about the dictionary items methods
    15. 05:01: Not using tuple unpacking
    16. 05:11: Creating your own index counter variable
    17. 05:21: Using “time.time()”” to time things
    18. 05:43: Littering your code with print statements instead of using the logging module
    19. 05:59: Using “shell = True” on any function in the subprocess library
    20. 06:13: Doing maths or any kind of data analysis in Python
    21. 06:23: Using “import *” outside of an interactive session
    22. 06:33: Depending on a specific directory structure for your project
    23. 07:07: The common misconception that Python is not compiled
    24. 07:34: Not following PEP 8
    25. 07:56: Doing anything to do with Python 2

  2. Muhammad Huzayfah より:

    #pycharm

  3. Markus M より:

    Absolutely amazing video. I’m very familiar with other languages but switching to python and your list is a perfect resource for that.

タイトルとURLをコピーしました