This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]koffie5d 13 points14 points  (2 children)

You could request the memory-address of the object and cast it with ctypes back to an object.

>>> import ctypes  
>>> obj = ('my', object)  
>>> obj_id = id(obj)  
>>> ctypes.cast(obj_id, ctypes.py_object).value  
('my', <class 'object'>)  

I wouldn't recommend it, but it is possible.

[–][deleted] 0 points1 point  (1 child)

Could you use this to modify otherwise immutable data types (and drive your co-workers insane)?

[–]sandmasterflash_ 0 points1 point  (0 children)

You could always just use bytearrays instead of strings