default_deepcopy
deepcopy, but if exception, return a default value
Installation
pip install default_deepcopy
Quickstart
from inspect import currentframe
import collections.abc
from src.default_deepcopy import default_deepcopy
class Dog:
pass
values = [
12200,
3.14159,
"apple",
True,
None,
[1, 2, 3],
(4, 5, 6),
{7, 8, 9},
{"apple":2, "orange": 5},
Dog(),
currentframe(),
collections.abc
]
for value in values:
value_copied = default_deepcopy(value, "<BAD VALUE>")
print(value, value_copied)
# 12200 12200
# 3.14159 3.14159
# apple apple
# True True
# None None
# [1, 2, 3] [1, 2, 3]
# (4, 5, 6) (4, 5, 6)
# {8, 9, 7} {8, 9, 7}
# {'apple': 2, 'orange': 5} {'apple': 2, 'orange': 5}
# <__main__.Dog object at 0x1026e7620> <__main__.Dog object at 0x1027c31d0>
# <frame at 0x1027...> <BAD VALUE>
# <module 'collections.abc' from ...> <BAD VALUE>
Why I wrote this
Too many helper functions doing this, so I abstracted it into a library
Release files for default-deepcopy 0.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| default_deepcopy-0.0.1.tar.gz | 2.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| default_deepcopy-0.0.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 4.2 kB
Release files / default_deepcopy-0.0.1.tar.gz
| Download URL | default_deepcopy-0.0.1.tar.gz |
|---|---|
| Size | 2.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
bb770a2f6d0ec477b5058d8f46f247ede523e19e1174dae09f383a462a8cc38f
|
|
BLAKE2b-256 checksum How to use checksums |
dfa28002003728e788a5af5f0ea50c78e4e83455c742353c5f9bdab97c92dc6f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.0.1 CPython/3.12.3
|
Release files / default_deepcopy-0.0.1-py3-none-any.whl
| Download URL | default_deepcopy-0.0.1-py3-none-any.whl |
|---|---|
| Size | 2.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
077fb05d4913e2479d09564aa62fefa40f2006ee5fe95990fa751bd887eac75c
|
|
BLAKE2b-256 checksum How to use checksums |
a4d41a64ce7af3f8105872c8b758e6721d024c477bbf7a31aa8ac7c003ac7e08
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.0.1 CPython/3.12.3
|