Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python force a condition

Tags:

python

Is there a way to force a condition to be true in Python? I've seen it being done in Haskell before and am wondering if you can do it Python. For example:

>>> 2+2==5
True
like image 644
Beta Decay Avatar asked Sep 09 '14 15:09

Beta Decay


1 Answers

Well you just need to set four equal to five.

import ctypes

def deref(addr, typ):
    return ctypes.cast(addr, ctypes.POINTER(typ))

deref(id(4), ctypes.c_int)[6] = 5

2 + 2
#>>> 5

2 + 2 == 5
#>>> True

Obviously...

like image 175
Veedrac Avatar answered Oct 27 '22 09:10

Veedrac