Serves empty files of many types
Project description
EmptyFiles.Python
TL;DR Null Object pattern for files.
Contents
This project will create an empty file of a type requested. If possible, that file will be the smallest valid file for that type. For example, an empty jpg will be a 1x1 pixel jpg.
Usage
This code:
from empty_files.empty_files import create_empty_file
create_empty_file("temp/empty.jpg")
will create the following image
Null Object Pattern
Issue: null/None causes extra checks in order to avoid errors.
Solution: return an empty version of the object, so methods can be used normally.
Example:
if last_name
returns ""
instead of None
,
we can write:
name_length = len(person.last_name())
instead of :
name_length = 0
if (person.last_name())
name_length = len(person.last_name())
Attributions
The empty files are taken from Simon Cropp's Empty Files.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
empty-files-0.0.1.tar.gz
(6.4 kB
view hashes)
Built Distribution
Close
Hashes for empty_files-0.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ceb4bc5d114bca563800a136b81d18284e47fa6b904ce99a7f3e1f753ee707fe |
|
MD5 | 96b445f496736a284bdc1b182beb069e |
|
BLAKE2b-256 | 7db38a415d755a77e060fda8b9e467c4cdc30ffadf2a4da505a3f769180f30ea |