modify immutable types by bypassing mapping proxy
Project description
Modifying sometype.__dict__
You can't directly set an attribute of a builtin type
int.real = 69
TypeError: cannot set 'real' attribute of immutable type 'int'
You also can't modify __dict__
int.__dict__["real"] = 69
TypeError: 'mappingproxy' object does not support item assignment
Mappingproxy provides a read-only proxy for mapping, which prevents modification. However, you can now bypass that using the bypassmappingproxy
module
(it is written in pure python)
from bypassmappingproxy as bmp
assert (1).real == 1
bmp.type_set(int, "real", 69)
assert (1).real == 69
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
Close
Hashes for bypassmappingproxy-0.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5387d31e1623398847148739a272e42ea3b92551300c9f29711043e6cfb93373 |
|
MD5 | 3e39bfa92d0f1111cc0ce130941e5de5 |
|
BLAKE2b-256 | c0d1845e93b5f534000413d62e046adaa45a9fced8a7517ec462deb7ed7d9677 |