[IPython-dev] Strange property bug?
Anand Patil
anand at soe.ucsc.edu
Fri May 18 22:52:51 EDT 2007
Hi all,
Here's a script I called 'test.py':
---------------------------------
class A(object):
c=1
def fget(self):
self.c=self.c+1
print 'Adding 1 to c'
b=property(fget)
M = A()
----------------------
From the regular Python shell, the A class works as expected:
Python 2.5 (r25:51918, Sep 19 2006, 08:49:13)
[GCC 4.0.1 (Apple Computer, Inc. build 5341)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from test import *
>>> M.c
1
>>> M.b
Adding 1 to c
>>> M.c
2
>>>
But in IPython, the fget function seems to get called twice:
IPython 0.8.0 -- An enhanced Interactive Python.
? -> Introduction to IPython's features.
%magic -> Information about IPython's 'magic' % functions.
help -> Python's own help system.
object? -> Details about 'object'. ?object also works, ?? prints more.
In [1]: run test
In [2]: M.c
Out[2]: 1
In [3]: M.b
Adding 1 to c
Adding 1 to c
In [4]: M.c
Out[4]: 3
Any ideas?
Thanks,
Anand
More information about the IPython-dev
mailing list