Grilled Cheese

ExploreLog inSign up

Trey Hunner

@trey.io

216 Following4k Followers

Python & Django team trainer

I help folks sharpen their Python skills with https://PythonMorsels.com 🐍πŸͺ

I also blog at https://treyhunner.com & run https://Whereabouts.Earth

PSF Fellow. YIMBY. 95% vegan.

PostsRepliesMedia
@trey.ioOct 13, 2026, 2:03 PM

πŸ—ΊοΈ October 13, 2026
5/5 countries in 5/13 guesses
🟒🟒🟒🟒🟒
whereabouts.earth/daily/
#Whereabouts

@trey.ioOct 12, 2026, 7:48 PM

πŸ—ΊοΈ October 12, 2026
5/5 countries in 9/13 guesses
🟒🟑🟑🟠🟒
whereabouts.earth/daily/
#Whereabouts

@trey.ioOct 12, 2026, 7:38 PM

How well do you know Python 3.15's new features? I made a quiz of some of my favorite features so you can test yourself.

@trey.ioOct 12, 2026, 6:02 PM

Note that help works offline. Even if you're stuck without Internet access, you can still read documentation. From your terminal, "python3 -m pydoc math" will show the same documentation you'd see with help(math) in a REPL.

@trey.ioOct 12, 2026, 6:02 PM

Once you're INSIDE the help pager (on Linux and Mac), you can use these keyboard shortcuts: β€’ Arrow keys (or j/k) to scroll β€’ / to search within the page β€’ q to quit On Windows, Enter scrolls a line, Space scrolls half a screen, and q quits.

@trey.ioOct 12, 2026, 6:02 PM

Pass a string to help to look up an operator or a keyword: >>> help("**") The power operator ****************** ... Not sure what you can look up? Ask help for "topics", "symbols", or "keywords".

@trey.ioOct 12, 2026, 6:02 PM

You can pass help a function, a module, a class, or even an instance of a class: >>> numbers = [2, 1, 3, 4] >>> help(numbers) Help on list object: class list(object) | list(iterable=(), /) ... Passing a class (or instance) shows the class docstring plus documentation for every method.

@trey.ioOct 12, 2026, 6:02 PM

Python Tip #285 (of 365):

Learn to use the help function. 🧡

>>> help(print)
Help on built-in function print in module builtins:

print(*args, sep=' ', end='\n', file=None, flush=False)
Prints the values to a stream, or to sys.stdout by default.
...

#Python #DailyPythonTip

@trey.ioOct 11, 2026, 11:59 PM

β€œDictionaries are meant to make it easy to look up the value that corresponds to a particular key.”

Read more πŸ‘‰ pym.dev/using-dictio...

#Python

@trey.ioOct 11, 2026, 2:48 PM

Why not use this in an installable package? sys.path is shared by the whole program. A library that inserts its own directories could shadow modules in the code that imports it. I'd rather see a package explicitly list dependencies than vendor those dependencies in a way that could break MY code.

@trey.ioOct 11, 2026, 2:48 PM

Unlike sys.path.append(...), sys.path.insert(0, ...) goes to the front. Python checks these directories in order, so YOUR module is found first, even if another directory has a module with the same name.

@trey.ioOct 11, 2026, 2:48 PM

The sys.path list contains the directories Python searches when looking for modules and packages to import. It's a plain list of strings, so you can add to it at runtime. Once your module's directory is in there, you can import your module as usual: import silly_module

@trey.ioOct 11, 2026, 2:48 PM

Python Tip #284 (of 365):

Import from another directory by adding it to sys.path. 🧡

sys.path.insert(0, str(Path(__file__).parent / "vendored_utils"))

This is a bit of a hack. It works great in your own project, but I wouldn't want to see it in an installable package.

#Python #DailyPythonTip

@trey.ioOct 11, 2026, 2:19 PM

πŸ—ΊοΈ October 11, 2026
5/5 countries in 5/13 guesses
🟒🟒🟒🟒🟒
whereabouts.earth/daily/
#Whereabouts

@trey.ioOct 10, 2026, 6:28 PM

β€œWhether something happens to be implemented as a class or a function is often just an implementation detail.”

Read more πŸ‘‰ pym.dev/class-or-fun...

#Python

@trey.ioOct 10, 2026, 3:24 PM

πŸ—ΊοΈ October 10, 2026
5/5 countries in 5/13 guesses
🟒🟒🟒🟒🟒
whereabouts.earth/daily/
#Whereabouts

@trey.ioOct 10, 2026, 3:04 PM

If you're curious about the new lazy imports in Python 3.15, see my screencast & article on my favorite 3.15 features.

@trey.ioOct 10, 2026, 2:48 PM

For either import style, I'd only do this for imports that are slow AND optional. And you probably don't want lazy imports in a web app. They'd make startup faster but the first request using each module slower. Slower startup and faster requests is usually the better tradeoff.

@trey.ioOct 10, 2026, 2:48 PM

Python 3.15 also adds EXPLICIT lazy imports, with the lazy keyword: lazy import matplotlib.pyplot as plt The import can stay at the top of the file, but the module isn't loaded until the first time plt is used. Until you upgrade to Python 3.15, a function-level import is pretty reasonable.

@trey.ioOct 10, 2026, 2:48 PM

One fix is to move the import into the function that needs it: def plot_results(results): import matplotlib.pyplot as plt ... Now matplotlib is only imported when plot_results is called. Tip #256 used this trick to work around a circular import. Here it's to reduce startup time instead.

Older posts
Terms of UsePrivacy PolicyCommunity StandardsHelpGet the app

Grilled Cheese is a product of Village Compute

Version devBuilt at: 2026-10-13 06:05:14 EDT