Skip to main content

Changes values in tuples using ctypes

Important: Never use this in a real project! Hacked tuples might lead to unexpected results!

from tuplechanger import tuplechanger


tutu = ('babaxxiq',-2,3.44, True, 800,1211)
print(id(tutu))
print(tutu)
tuindex = 0
tuplechanger(tutu, tuindex, 'bbbbxxxi')
print(tutu)
tuindex = 1
tuplechanger(tutu, tuindex, -4)
print(tutu)
tuindex = 2
tuplechanger(tutu, tuindex, 13.44)
print(tutu)
tuindex = 3
tuplechanger(tutu, tuindex, False)
print(tutu)
tuindex = 4
tuplechanger(tutu, tuindex, 17000)
print(tutu)
tuindex = 5
tuplechanger(tutu, tuindex, 1111)
print(tutu)
print(id(tutu))
# 1843849020512
# ('babaxxiq', -2, 3.44, True, 800, 1211)
# ('bbbbxxxi', -2, 3.44, True, 800, 1211)
# ('bbbbxxxi', -4, 3.44, True, 800, 1211)
# ('bbbbxxxi', -4, 13.44, True, 800, 1211)
# ('bbbbxxxi', -4, 13.44, False, 800, 1211)
# ('bbbbxxxi', -4, 13.44, False, 17000, 1211)
# ('bbbbxxxi', -4, 13.44, False, 17000, 1111)
# 1843849020512

Why you shouldn't use it in a real project:

# It looks pretty good as first sight, but ... 
# tutu[0] + 'xxxx'
# Out[3]: 'bbbbxxxixxxx'
# tutu[1] + 5
# Out[4]: 1
# tutu[2] + 5.999
# Out[5]: 19.439
# tutu[3] is False
# Out[6]: True
# tutu[4] > 15000
# Out[7]: True
# tutu[5] < 1200
# Out[8]: True
# tutu[-1] < 1200
# Out[9]: True
# tutu[-2] < 15000
# Out[10]: True
# tutu[-3] is False
# Out[11]: True
# tutu[-4] + 5.999
# Out[12]: 19.439
# tutu[1] + 5
# Out[13]: 1

# ... it isn't a good idea to hack tuples:


# tutu[2] + tutu[4]   # positive index, everything is fine 
# Out[3]: 17013.44


# WRONG!!!
# tutu[-2] + tutu[-4] # negative index, crap
# Out[6]: 26.88

Metadata

Release files for tuplechanger 0.10

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

Source distribution (sdist)

Source distribution for tuplechanger 0.10
File Size Uploaded Provenance Actions
tuplechanger-0.10.tar.gz 5.6 kB Without provenance Details for tuplechanger-0.10.tar.gz

Built distribution (wheel)

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

Total release size: 12.6 kB

Release files / tuplechanger-0.10.tar.gz

Download URL tuplechanger-0.10.tar.gz
Size 5.6 kB
Tags Source
SHA-256 checksum
How to use checksums
99a48d124c063d2fbe3eb1b01b9c4e031294a7d0910f05df7b2ae330ed4ffb97
BLAKE2b-256 checksum
How to use checksums
6521dfdf4201f2558fe82988dcb16530b1eadbe763ab59cde05b1ccb4fd1a29b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.10

Release files / tuplechanger-0.10-py3-none-any.whl

Download URL tuplechanger-0.10-py3-none-any.whl
Size 7.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
579d71c986bf20679a851a55a0cefcea8e20484ddfa66d6512ef4e376160f1ed
BLAKE2b-256 checksum
How to use checksums
64e4e930e04810faa06073bacad75df647c3d1e39804b5ab2bc4f93efaea6f52
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.10

Security for tuplechanger 0.10

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

0.10 This release

2 release files 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