Sequences are iterables that have a length. Sequences are ordered collections (they maintain the order of their contents). The most common sequences built-in to Python are string, tuple, and list.| www.pythonmorsels.com
Is your Python program printing out a traceback? You have an uncaught exception! You can catch that exception with a try-except block.| www.pythonmorsels.com
Python crashed with the error TypeError: can only concatenate str (not "int") to str. Essentially Python's saying you've used + between a string and a number and it's unhappy about it. Let's talk about how to fix this issue and how to avoid it more generally.| www.pythonmorsels.com
Python's strings have dozens of methods, but some are much more useful than others. Let's discuss the dozen-ish must-know string methods and why the other methods aren't so essential.| www.pythonmorsels.com
In Python, slicing looks like indexing with colons (:). You can slice a list (or any sequence) to get the first few items, the last few items, or all items in reverse.| www.pythonmorsels.com
In Python, truthiness is asking the question, what happens if I convert an object to a boolean. Every Python object is truthy by default. Truthiness in Python is about non-emptiness and non-zeroness.| www.pythonmorsels.com
Python's built-in enumerate function is the preferred way to loop while counting upward at the same time. You'll almost always see tuple unpacking used whenever enumerate is used.| www.pythonmorsels.com
Any reversible iterable can be reversed using the built-in reversed function whereas Python's slicing syntax only works on sequences.| www.pythonmorsels.com
Unlike traditional C-style for loops, Python's for loops don't have indexes. It's considered a best practice to avoid reaching for indexes unless you really need them.| www.pythonmorsels.com
Python's dictionaries act as lookup tables which map keys to their values.| www.pythonmorsels.com
To work with a text file in Python, you can use the built-in open function, which gives you back a file object. Reading from and writing to text files is an important skill.| www.pythonmorsels.com
Classes are for coupling state (attributes) and functionality (methods). Calling a class returns an instance of that class. Class and "type" are synonyms in Python.| www.pythonmorsels.com
Within a function in Python, you can read from global variables and read from or write to local variables. Within each function, each variable name is either local or global (but not both).| www.pythonmorsels.com
Python's list comprehensions are special-purpose tools for taking an old iterable, looping over it, and making a new list out of it.| www.pythonmorsels.com
The Python REPL is another name for Python's interactive Python interpreter, which accepts Python statements and immediately evaluates them.| www.pythonmorsels.com
Occasionally in Python (and in programming in general), you’ll need an object which can be uniquely identified. Sometimes this unique object …| treyhunner.com
Source code: Lib/numbers.py The numbers module ( PEP 3141) defines a hierarchy of numeric abstract base classes which progressively define more operations. None of the types defined in this module ...| Python documentation
Source code: Lib/importlib/__init__.py Introduction: The purpose of the importlib package is three-fold. One is to provide the implementation of the import statement (and thus, by extension, the__i...| Python documentation
List comprehensions make lists; generator expressions make generators. Generators are lazy single-use iterables which generate values as you loop over them.| www.pythonmorsels.com
An iterable is anything you're able to iterate over (iter-able). Iterables can be looped over and anything you can loop over is an iterable. Not every iterable is indexable or has a length.| www.pythonmorsels.com
Source code: Lib/_collections_abc.py This module provides abstract base classes that can be used to test whether a class provides a particular interface; for example, whether it is hashable or whet...| Python documentation
While The Python Language Reference describes the exact syntax and semantics of the Python language, this library reference manual describes the standard library that is distributed with Python. It...| Python documentation
This module implements a number of iterator building blocks inspired by constructs from APL, Haskell, and SML. Each has been recast in a form suitable for Python. The module standardizes a core set...| Python documentation
When should you use the built-in list function in Python? And when shouldn't you?| www.pythonmorsels.com
Objects, values and types: Objects are Python’s abstraction for data. All data in a Python program is represented by objects or by relations between objects. (In a sense, and in conformance to Von ...| Python documentation
Definitions for colloquial Python terminology (effectively an unofficial version of the Python glossary).| www.pythonmorsels.com
Comparing things in Python. That sounds like something that almost doesn’t even need to be taught. But I’ve found that Python’s …| treyhunner.com