From 26630ea4b6658a6b700bd227dd61e5207efeb5f4 Mon Sep 17 00:00:00 2001 From: whitequark Date: Sat, 28 Nov 2015 08:29:58 +0800 Subject: [PATCH] language.core: make int compatible with range() (fixes #183). --- artiq/language/core.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/artiq/language/core.py b/artiq/language/core.py index b588d7887..917a6e11a 100644 --- a/artiq/language/core.py +++ b/artiq/language/core.py @@ -85,6 +85,10 @@ class int: def __str__(self): return str(self._value) + # range() etc call __index__, not __int__ + def __index__(self): + return self._value + def __repr__(self): return "int({}, width={})".format(self._value, self._width)