Common Questions
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.
- 1 - 13 of 13
- 1
Sometimes it is useful to access both the current and next item when iterating over a list. |
The asker is surprised that their |
Unpacking assignment from a list, tuple, map, etc. into separate names |
Python 2 and 3 allow tabs to be used to indent lines. Python 2 will expand these to a multiple of 8, in Python 3 a tab can be equal only to another tab;, but many editors and Stack Overflow expand tabs to multiples of 4 instead. This can lead to subtle and weird flow errors. |
|
Zip can be used to iterate over multiple lists at the same time. In Python 3.x a generator is used whilst in Python 2.x a new list of tuples is created, as such itertools.izip may be a better choice. |
Python throws an error if you modify the |
How to remove items from a list while iterating over the same list without skipping elements. |
The result set of a single column query is a list of tuples, instead of a list |
Sorting a list of version strings, eg |
How to split a single list into multiple lists with a fixed (maximum) size? |
The splat operator (*) can be used to unpack variables from a container when calling a function. |
- 1 - 13 of 13
- 1