This is a list of common questions within the Python tag. Each question includes some canonical SO questions that can be used to close-vote any new questions that match. If you have any suggestions then please come see us in chat.

  • Each space separated value is a separate search term.
  • Terms are ANDed together.
  • [Brackets] indicate a tag term.
  • is:draft shows only draft posts.
  • is:community shows only community posts.
  • 101 - 119 of 119

Seeing something like @contract.bind indicates a decorator function in python.

A docstring is a the first unassigned string in a function, class, or module declaration.

The terminology makes finding a canonical “That’s a list / dict / etc. comprehension” question hard.

Why doesn’t my Python execute in this rendered JavaScript?

The representation of a string with backslashes can sometimes throw a user as they are escaped.

If a function does not return a value then it automatically returns None.

Python parses 2. as the float 2.0, this can cause troubles when trying to use methods on integers.

Testing against multiple values using boolean operators, sometimes people think booleans work like English grammar.

The OP expects a variable in their callback lambdas to have the value it had when the function was created, instead it has the current value at calling time.

Strings are immutable, so methods on the string that alter the string return a new value. Typically beginners forget this and call str.upper() or str.lower() or str.title() or str.replace() or str.strip() without assigning the new string back to the variable.

It’s a hardware issue.

The way Python handles newlines on Windows can result in blank lines appearing between rows when using csv.writer.

  • 101 - 119 of 119