In CPython, __builtins__ is a module for the main script, but it is a dictionary for modules. This is quite confusing, and this behaviour is explicitly stated as an implementation detail. As far as I can tell, it is always a module in IronPython.
http://docs.python.org/lib/module-builtin.html However, far too many existing CPython sources break beacuse of this on IronPython for my taste. The symptom is: TypeError: <type '__builtin__'> is not enumerable This is usually caused by well-intended codes as following: if 'sorted' not in __builtins__: def sorted(seq): seq = seq[:] seq.sort() return seq This lets one to keep compatibility with CPython versions before 2.4, while still using 2.4-introduced sorted() builtin. Here are some existing usages: http://www.google.com/codesearch?q=%22in+__builtins__%22 -- Seo Sanghyeon _______________________________________________ users mailing list [email protected] http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
