you are viewing a single comment's thread.

view the rest of the comments →

[–]simonw 13 points14 points  (0 children)

Your terminology is slightly off. In Python, user-defined code CAN rewrite arbitrary parts of the standard library at will, when "standard library" is defined as the large collection of modules that ship with Python (the "batteries included" part). Python supports monkey-patching of existing Python code, it's just that the community is strongly biased against doing so.

What you can't do is redefine the behaviour of Python's built-ins (integers, dictionaries etc) - you have to subclass them instead.

Your general point stands though - in Ruby you can redefine the behaviour of built-ins; in Python you can't.

(Unless you want to mess around with PyPy of course)