Hi. Yes, those two things are equivalent and they both work. However, if you try to read the file immediately after deleting the variable, you'll find out that the file is empty on any implementation but cpython.
On Thu, Aug 19, 2010 at 6:25 AM, sakesun roykiatisak <[email protected]> wrote: > Hi, > I encountered this quite a few times when learning pypy from internet > resources: > the code like this >>>> open(’xxx’, ’w’).write(’stuff’) > This code is not working on pypy because it rely on CPython refcounting > behaviour. > I don't get it. Why ? I thought the code should be similar to storing the > file object in temporary variable like this >>>> f = open('xxx', 'w') >>>> f.write('stuff') >>>> del f > Also, I've tried that with both Jython and IronPython and they all work > fine. > Why does this cause problem to pypy ? Do I have to avoid writing code like > this in the future ? > _______________________________________________ > [email protected] > http://codespeak.net/mailman/listinfo/pypy-dev > _______________________________________________ [email protected] http://codespeak.net/mailman/listinfo/pypy-dev
