Tuples are technically just immutable lists, but by convention we tend to use tuples and lists for quite different purposes.| www.pythonmorsels.com
To use a function in Python, write the function name followed by parentheses. If the function accepts arguments, pass the arguments inside the parentheses.| www.pythonmorsels.com
Want to turn a list of strings into a single string? You can use the string join method to join a list of strings together (concatenating them with a delimiter of your choice).| www.pythonmorsels.com
In Python, strings are used to represent text and bytes are used to represent binary data. If you end up with bytes that representing text, you can decode them to get a string instead.| www.pythonmorsels.com
In Python we care about the behavior of an object more than the type of an object. We say, "if it looks like a duck and walks like a duck, it's a duck." This idea is called duck typing.| www.pythonmorsels.com
Python's collections.Counter class is extremely handy, especially when paired with generator expressions.| www.pythonmorsels.com
Instead of using hard-coded indices to get tuple elements, use tuple unpacking to give descriptive names to each item. Important items should have a name instead of a number.| www.pythonmorsels.com
The range function can be used for counting upward, countdown downward, or performing an operation a number of times.| www.pythonmorsels.com
Need to loop over two (or more) iterables at the same time? Don't use range. Don't use enumerate. Use the built-in zip function. As you loop over zip you'll get the n-th item from each iterable.| www.pythonmorsels.com
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
Context managers power Python's with blocks. They sandwich a code block between enter code and exit code. They're most often used for reusing common cleanup/teardown functionality.| 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
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
Python's built-in functions list includes 71 functions now! Which built-in functions are worth knowing about? And which functions should you learn later?| 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
Iterators are lazy iterables which power all iteration in Python. Iterators are the generic form of a generator-like object.| 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
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
Python's built-in next function will consume the next item from a given iterator.| www.pythonmorsels.com
When should you use the built-in list function in Python? And when shouldn't you?| www.pythonmorsels.com
You don't need third-party libraries to read CSV file in Python! Python's csv module includes helper functions for reading CSV files, tab-delimited files, and other delimited data files.| www.pythonmorsels.com
Definitions for colloquial Python terminology (effectively an unofficial version of the Python glossary).| www.pythonmorsels.com
Unlike many programming languages, variables in Python are not buckets which "contain" objects. In Python, variables are pointers that "point" to objects.| www.pythonmorsels.com