[pypy-dev] Here's a fun one...

Dino Viehland dinov at microsoft.com
Thu Sep 1 05:28:42 CEST 2011

This came up on an internal discussion, I thought it was fun, especially given that we all behave differently:

Paste this into the REPL:

class PS1(object):
  def __init__(self): self.count = 0
  def __str__(self):
    self.count += 1
    return "%d >>>" % self.count

import sys
sys.ps1 = PS1()

CPython  - calls __str__
Jython - calls __repr__
IronPython - ignores ps1
PyPy - unsupported operand type for unary buffer: 'PS1'

(note I don't necessarily have the latest versions for everyone)

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/pypy-dev/attachments/20110901/fee42e66/attachment.html>

More information about the pypy-dev mailing list