25 nooby Python habits you need to ditch
mCoding・9 minutes read
Use f strings for string formatting, utilize a with statement to close files, opt for context managers, avoid bare except clauses, understand XOR, be cautious with default mutable arguments, use comprehensions, but don't overuse them.
Insights
- Use f strings for string formatting instead of the plus sign; they are more readable and less error-prone.
- Avoid manually closing files; utilize a with statement to ensure proper closure even in case of exceptions.
Get key ideas from YouTube videos. It’s free
Recent questions
How should I format strings in Python?
Use f strings for string formatting instead of the plus sign; they are more readable and less error-prone.
What is the best way to handle file closure in Python?
Avoid manually closing files; utilize a with statement to ensure proper closure even in case of exceptions.
How should I handle resource management in Python?
Opt for context managers over try-finally for resource handling in Python.
What is the importance of specific exception handling in Python?
Refrain from using bare except clauses; catch specific exceptions to avoid unintended catches like keyboard interrupts.
When should I use list comprehensions in Python?
Utilize comprehensions, including list, dictionary, set, and generator comprehensions, for concise and clear code.
Related videos
Vishal Kumar
Chapter 7 Python Fundamentals One Shot | Class 11 Computer Science |Class 11 Python | Vishal Kumar
BECAUSE
5.3. Principal Sources of Optimization Part 3 in Tamil
freeCodeCamp.org
12 Beginner Python Projects - Coding Course
College Wallah
C Programming in One Shot | Part 1 | Variables, Operators and Input/ Output | C Complete Course
Fireship
Reacting to Controversial Opinions of Software Engineers