Re: Help! File objects and scoping

2005-06-08 Thread bens
Dave Benjamin wrote: > Here's the problem: the "mmap" object doesn't have a reference to > "somefile", only to its file descriptor number. So, when getfile() goes > out of scope, there are no references left, and the file gets closed > automatically. That makes a lot of sense. It's now how I woul

Re: Help! File objects and scoping

2005-06-07 Thread Dave Benjamin
bens wrote: > I'm trying to return an 'mmap' object from a function. The return > works, but some of the object's methods crash. Here are two examples > > doesntwork.py > --- > import mmap > import os > > name="/any/real/file/on/my/hard/drive" > > def getfile(name): >

Re: Help! File objects and scoping

2005-06-07 Thread Kent Johnson
bens wrote: > I'm trying to return an 'mmap' object from a function. The return > works, but some of the object's methods crash. Here are two examples > > doesntwork.py > --- > import mmap > import os > > name="/any/real/file/on/my/hard/drive" > > def getfile(name): >

Help! File objects and scoping

2005-06-07 Thread bens
I'm trying to return an 'mmap' object from a function. The return works, but some of the object's methods crash. Here are two examples doesntwork.py --- import mmap import os name="/any/real/file/on/my/hard/drive" def getfile(name): somefile=file(name, 'r+b') mm