deepcopy, but if exception, return default value instead of raising exception
Project description
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
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file default_deepcopy-0.0.1.tar.gz.
File metadata
- Download URL: default_deepcopy-0.0.1.tar.gz
- Upload date:
- Size: 2.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bb770a2f6d0ec477b5058d8f46f247ede523e19e1174dae09f383a462a8cc38f
|
|
| MD5 |
8ac4a9c88003e3124df3b95e449c5946
|
|
| BLAKE2b-256 |
dfa28002003728e788a5af5f0ea50c78e4e83455c742353c5f9bdab97c92dc6f
|
File details
Details for the file default_deepcopy-0.0.1-py3-none-any.whl.
File metadata
- Download URL: default_deepcopy-0.0.1-py3-none-any.whl
- Upload date:
- Size: 2.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
077fb05d4913e2479d09564aa62fefa40f2006ee5fe95990fa751bd887eac75c
|
|
| MD5 |
b45a9f580fc9bcf416b62875b1fa6d76
|
|
| BLAKE2b-256 |
a4d41a64ce7af3f8105872c8b758e6721d024c477bbf7a31aa8ac7c003ac7e08
|