Python
fromInfoWorld
18 hours agoGet started with Python's new frozendict type
Python 3.15 introduces frozendict, an immutable dictionary that is hashable and useful in scenarios where regular dictionaries cannot be used.
"One story stands out to me beyond getting to know each other and sharing ideas. When I was getting ready to give my first PyCon talk in Montreal, Selena Deckelmann offered to help review my slides and listen to me practice. We spent a few hours on the floor of her hotel room prepping while her very young daughter crawled around on the floor and chewed on my PyCon badge since she was teething. It's still one of my favorite PyCon and PyLadies memories." - Carol Willing, Willing Consulting
The WAV file is a valid audio file. It passes MIME-type checks. But the audio frame data contains a base64-encoded payload. Decode the frames, take the first 8 bytes as the XOR key, XOR the rest, and you have your executable or Python script.
Python makes it straightforward to download files from a URL with its robust set of libraries. For quick tasks, you can use the built-in urllib module or the requests library to fetch and save files. When working with large files, streaming data in chunks can help save memory and improve performance.
You'll explore how I/O-bound programs face latency, which concurrency patterns to use, the differences between threading, asyncio, and multiprocessing, and how the Global Interpreter Lock (GIL) affects Python programs.
By working through this quiz, you'll revisit the descriptor protocol, how .__get__() and .__set__() control attribute access, and how to implement read only descriptors. You'll also explore data vs. non-data descriptors, attribute lookup order, and the .__set_name__() method.
A directory without an __init__.py file becomes a namespace package, which behaves differently from a regular package and may cause slower imports. You can use __init__.py to explicitly define a package's public API by importing specific modules or functions into the package namespace.
Mocking in Python with unittest.mock allows you to simulate complex logic or unpredictable dependencies, such as responses from external services. The Mock class can imitate real objects, and the patch() function lets you temporarily substitute mocks for real objects in your tests.