Skip to main content

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

reference

Metadata

Release files for bypassmappingproxy 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for bypassmappingproxy 0.1.0
File Size Uploaded
bypassmappingproxy-0.1.0.tar.gz 1.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for bypassmappingproxy 0.1.0
File Interpreter ABI Platform
bypassmappingproxy-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 3.4 kB

Release files / bypassmappingproxy-0.1.0.tar.gz

Download URL bypassmappingproxy-0.1.0.tar.gz
Size 1.5 kB
Tags Source
SHA-256 checksum
How to use checksums
bfb9fabfd0d97702c75300d119a858c9edeb7de56fde0b323f1a27693caeca62
BLAKE2b-256 checksum
How to use checksums
c75113780e21aab0549b0168fd0647a9219c6ecac72c560a3d2a1fc441c8d1b8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.11.2

Release files / bypassmappingproxy-0.1.0-py3-none-any.whl

Download URL bypassmappingproxy-0.1.0-py3-none-any.whl
Size 1.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5387d31e1623398847148739a272e42ea3b92551300c9f29711043e6cfb93373
BLAKE2b-256 checksum
How to use checksums
c0d1845e93b5f534000413d62e046adaa45a9fced8a7517ec462deb7ed7d9677
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.11.2

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page