Skip to main content
# Assign

---------

`assign` is a black magic module for supporting `obj.__assign__`:

### How to use it:

#### 1. magic patch

Suppose that there is a `test.py`

```python

a = 1


class T():
def __assign__(self, v):
print('called with %s' % v)


b = T()
c = b

```
It just works as:

```python
Python 3.6.0 (default, Mar 6 2017, 15:44:48)
[GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.42.1)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import magic
>>> import test
called with c

```

#### 2. manually patch

```
from assign.patch import patch_module
import test

patch_module(test)

```

### Install

just:

`pip install assign`

### Notes

* Tested with `Py2.7` and `Py3.6`

### Known Issues

* 1. Won't work under `REPL`
* 2. May slow import operation.
* 3. May failed when patch some modules like `os` and `sys`

Metadata

Release files for assign 1.0.1

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

Source distribution (sdist)

Source distribution for assign 1.0.1
File Size Uploaded Provenance
assign-1.0.1.tar.gz 3.0 kB Without provenance Details

Release files / assign-1.0.1.tar.gz

Download URL assign-1.0.1.tar.gz
Size 3.0 kB
Tags Source
SHA-256 checksum
How to use checksums
fd2019d9686e3595f287eb671e337fc9bccac14857307c446317e88aa46b8bf5
BLAKE2b-256 checksum
How to use checksums
e6d6a888ae6f85f4caeac23e3190dc659e977d4b8073d6dd82f4ed1a6ed73d33
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for assign 1.0.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.0.1 This release

1 release file No provenance

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