Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Basic] Various Python Gotchas
#1
Python will trip you up at some point or another. It sometimes can feel like a bug when its not. What people define as a gotcha depends on who you are and a number of other variables. One person's common sense might be another's gotchas and vice versa. It can depend on what operating system you are using, what python version you are using, what IDE you are using, what language you learned before python, how much knowledge acquire regarding python, what your native speaking language is (language barrier), etc.

Multiple Expressions with or keyword
This is a trip up for so many it needs its own thread
http://python-forum.io/Thread-Multiple-e...or-keyword

range(len(sequence)) in for loops
Another one that deserves its own thread
https://python-forum.io/Thread-Basic-Nev...n-sequence

Install the correct bittype version for a 3rd party library

Linux is case sensitive

Naming your scripts and directories

Forgetting __init__.py in your sub-directories
Python2.x requires a __init__.py file in all of your sub-directories. Python3.x it is optional.

Modifying a list (or other container) while iterating over it

Having circular module dependencies

Using global keyword when you should be using a class

empty list in a function argument 

Failing to address differences between Python 2 and Python 3

I cant find where python installed
https://python-forum.io/Thread-Python-3-...6#pid11496

index variables leak into enclosing scope
Talbot9 likes this post
Recommended Tutorials:
Reply


Messages In This Thread
Various Python Gotchas - by metulburr - Oct-27-2016, 03:13 PM
RE: Python Gotchas - by micseydel - Nov-03-2016, 06:03 PM
RE: Python Gotchas - by metulburr - Nov-03-2016, 07:57 PM
RE: Python Gotchas - by micseydel - Nov-03-2016, 08:45 PM
RE: Python Gotchas - by metulburr - Nov-03-2016, 08:54 PM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020