On 01/09/11 05:28, Dino Viehland wrote:
This came up on an internal discussion, I thought it was fun, especially given
that we all behave differently:

Paste this into the REPL:
[cut]

it seems to work fine with pypy 1.6. Note that str() is called twice for each line, so we get 1, 3, 5, 7..., but this happens only on cpython.

>>>> class PS1(object):
....   def __init__(self):
....       self.count = 0
....   def __str__(self):
....       self.count += 1
....       return "%d >>>" % self.count
....
>>>> import sys
>>>> sys.ps1 = PS1()
1 >>>
3 >>>
5 >>>
7 >>>
9 >>>

ciao,
Anto
_______________________________________________
pypy-dev mailing list
pypy-dev@python.org
http://mail.python.org/mailman/listinfo/pypy-dev

Reply via email to