|
🔗 Stories, Tutorials & Articles |
|
|
|
Django Model Fields With Attributes |
|
|
A custom Django model field called MarkdownField is created to store a string as the underlying data but exposes additional attributes on model instances. The implementation involves a field class, a Python descriptor, and a final value object. The descriptor overrides attribute access and sets the underlying data, while the value object wraps the actual value and provides extra functionality such as converting Markdown to HTML. This approach allows for sub-attributes on fields and provides clarity when assignments need to be handled. |
|
|
|
|
|
|
Python dependency management redux |
|
|
One major drawback of Python's ecosystem is the significant variances in workflows for different tasks, including dependency management. Depending on the specific use case, such as web development or data science, the workflow can vary greatly. The author shares their preferred approach, which involves using pip and pip-tools for managing dependencies in applications, and hatch for packaging libraries. |
|
|
|
|
|
|
Documenting Native Python Extensions Made With Rust and PyO3 |
|
|
Python developers can create well-documented native extensions using Rust and PyO3 by leveraging the Sphinx documentation builder and the Napoleon extension. By utilizing Rust's documentation blocks with Sphinx's RST syntax, developers can generate documentation for Rust code that can be seamlessly integrated into the Sphinx documentation. This approach simplifies the process of documenting and publishing Python extensions written in Rust, providing an efficient solution for creating optimized and well-documented code. |
|
|
|
|
|
|
Problems faced when downstream testing Python packages |
|
|
Downstream testing, performed by software redistributors like Linux distributions, serves a different purpose than upstream testing. While upstream testing ensures the current code works in reference environments, downstream testing verifies that a specific package version functions properly in the intended environment. However, downstream testers often encounter issues with test suites that assume a disposable environment, require outdated package versions, have incompatibilities caused by additional packages, rely on internet resources, demand containers for testing, include fragile tests with timeouts, impose unconditional test dependencies, or conduct package quality checks that may not be critical for downstream purposes. |
|
|
|
|
|
|
Designing Pythonic library APIs ✅ |
|
|
Principles useful for designing good Python library APIs, including structure, naming, error handling, and type annotations. |
|
|
|
|
|
|
Generating Code without Generating Technical Debt? |
|
|
GPT and other large language models can generate large volumes of code quickly, allowing for faster prototyping and iterative development. However, this can also result in a larger amount of messy code to maintain. There are ways to improve the code generated by these models, such as following best practices, providing specific instructions, and iterating on the generated code to make it better. |
|
|
|
|
|
|
Git and Jupyter Notebooks: The Ultimate Guide |
|
|
Use git version control with Jupyter Notebook for many advantages, but there are challenges such as reviewing local notebook changes and resolving merge conflicts. Tools like nbdime, JupyterLab Git extension, and ReviewNB can help address these challenges and improve collaboration with Jupyter Notebook and Git. |
|
|
|
|